Skip to content

Instantly share code, notes, and snippets.

@krasnoukhov
Last active August 29, 2015 14:17
Show Gist options
  • Save krasnoukhov/0f69d40909f53657387f to your computer and use it in GitHub Desktop.
Save krasnoukhov/0f69d40909f53657387f to your computer and use it in GitHub Desktop.
INSTANCE EVALER!
omg = Class.new do
attr_accessor :test1
attr_accessor :test2
def inspect
puts "test1", test1.inspect
puts "test2", test2.inspect
puts "="*40
end
end
wow = omg.new
wow.inspect
wow.instance_eval(IO.read("smth.rb"))
wow.inspect
test1
nil
test2
nil
========================================
test1
"wow1"
test2
"wow2"
========================================
instance_eval(IO.read("template.rb"))
self.test1 = "wow1"
self.test2 = "wow2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment