Created
April 7, 2015 06:51
-
-
Save Zkuns/16aa21e453adda939384 to your computer and use it in GitHub Desktop.
test method_missing method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Awesome | |
def initialize | |
@attr = {} | |
end | |
def attr | |
@attr.to_s | |
end | |
def method_missing name, *arg | |
name = name.to_s | |
if name =~ /=/ | |
@attr[name.chop] = arg[0] | |
else | |
@attr[name] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment