-
-
Save baweaver/b03dfa78473439cb3ef3af506e9a4d68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'binding_of_caller' | |
class Evil | |
def initialize(other_binding, *vs) | |
@other_binding = other_binding | |
@vs = vs | |
end | |
def <(other) | |
@vs.each { |v| @other_binding.local_variable_set(v, other[v]) } | |
end | |
end | |
class Object | |
def sets(bind,*vs) | |
Evil.new(binding.of_caller(2), *vs) | |
end | |
end | |
sets(:a, :b) < {a: 1, b: 2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment