Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created February 20, 2018 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baweaver/b03dfa78473439cb3ef3af506e9a4d68 to your computer and use it in GitHub Desktop.
Save baweaver/b03dfa78473439cb3ef3af506e9a4d68 to your computer and use it in GitHub Desktop.
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