Skip to content

Instantly share code, notes, and snippets.

@krasnoukhov

krasnoukhov/omg.rb

Last active Aug 29, 2015
Embed
What would you like to do?
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