Created
August 20, 2008 08:48
-
-
Save tmm1/6345 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 ConstSetter(opts) | |
(@@__const_setter__modules ||= {})[opts] ||= Module.new do |m| | |
def m.included c | |
@@__const_setter__modules.index(self).each do |key, val| | |
c.const_set(key, val) | |
end | |
end | |
end | |
end | |
class Test | |
include ConstSetter(:TestConst => 123) | |
end | |
p Test::TestConst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment