Created
May 7, 2009 18:26
-
-
Save bryanl/108261 to your computer and use it in GitHub Desktop.
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
| def const_accessor(sym, value, remove=false, freeze=true) | |
| value.deepfreeze if freeze | |
| sym = sym.to_s | |
| down, up = sym.downcase, sym.upcase | |
| sym = up.to_sym | |
| remove_const sym if remove and const_defined? sym | |
| const_set sym, value | |
| class_eval "def #{down}; #{up}; end\ndef self.#{down}; #{up}; end" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment