Skip to content

Instantly share code, notes, and snippets.

@watson
Created August 17, 2011 12:29
Show Gist options
  • Save watson/1151439 to your computer and use it in GitHub Desktop.
Save watson/1151439 to your computer and use it in GitHub Desktop.
How to access a class constant dynamically from inside a module when the module is included into the class
module Foo
def foo
# This does not work:
# TYPES
# This works:
self.class.const_get('TYPES')
end
end
class Bar
TYPES = 'You found me!'
include Foo
end
Bar.new.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment