Constructing Ruby Class Instances from a String
OK, little bit of Rubyfoo here:
I should spend some more time in the Pickaxe book to try to pick up some more things like this...
class Person
def say_hello
puts "hello"
end
end
class_name = "Person"
person_class = Object.const_get(class_name)
person = person_class.new
person.say_hello
I should spend some more time in the Pickaxe book to try to pick up some more things like this...
0 Comments:
Post a Comment
<< Home