Skip to content

Instantly share code, notes, and snippets.

@tmm1
Created August 20, 2008 08:48
Show Gist options
  • Save tmm1/6345 to your computer and use it in GitHub Desktop.
Save tmm1/6345 to your computer and use it in GitHub Desktop.
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