class Shop
def self.name
"kids-toy"
end
def self.postcode
1000
end
end
methods = ["name", "postcode"]
methods.each {|m|
mcall = "Shop.#{m}"
eval mcall
}
Is there any other way rather than calling eval
to invoke methods which are elements of an array?