Created
March 16, 2018 21:57
-
-
Save anonymous/6f80c75f80c9beacac547ce21901f787 to your computer and use it in GitHub Desktop.
This file contains 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
def method_missing(method_name, *args, &blk) | |
return self.[](method_name, &blk) if key?(method_name) | |
name, suffix = method_name_and_suffix(method_name) | |
case suffix | |
when '='.freeze | |
assign_property(name, args.first) | |
when '?'.freeze | |
!!self[name] | |
when '!'.freeze | |
initializing_reader(name) | |
when '_'.freeze | |
underbang_reader(name) | |
else | |
self[method_name] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment