Created
July 16, 2014 12:19
-
-
Save garrypolley/fbc52427cdb70ab6bbd7 to your computer and use it in GitHub Desktop.
Making the world a little crazier with Ruby. This could obviously be more robust.
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 DynamicSingletonMethods | |
| def method_missing(meth,*args,&block) | |
| method_string = meth.to_s | |
| if method_string.end_with? '=' | |
| method = method_string.split('=')[0] | |
| self.define_singleton_method(method.to_sym) do args[0] end | |
| else | |
| super | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment