Check out this one, this is way i love rails.
elad = "smart"
elad.smart? # => true
using method_missing on the String object
def method_missing(method_name, *arguments)
if method_name.to_s.ends_with?("?")
self == method_name.to_s[0..-2]
else
super
end
end
0 comments:
Post a Comment