Module: ConstantCache
- Defined in:
- lib/constant_cache/cache_methods.rb
Defined Under Namespace
Modules: ClassMethods Classes: DuplicateConstantError
Constant Summary collapse
- CHARACTER_LIMIT =
64
Class Method Summary collapse
Instance Method Summary collapse
-
#set_instance_as_constant ⇒ Object
Create a constant on the class that pointing to an instance.
Class Method Details
.cache! ⇒ Object
10 11 12 |
# File 'lib/constant_cache/cache_methods.rb', line 10 def self.cache! @descendants.each {|klass| klass.cache!} end |
.included(model) ⇒ Object
5 6 7 8 |
# File 'lib/constant_cache/cache_methods.rb', line 5 def self.included(model) model.extend(ClassMethods) (@descendants ||= []) << model end |
Instance Method Details
#set_instance_as_constant ⇒ Object
Create a constant on the class that pointing to an instance
75 76 77 78 79 |
# File 'lib/constant_cache/cache_methods.rb', line 75 def set_instance_as_constant unless constant_name.nil? || self.class.const_defined?(constant_name) self.class.const_set(constant_name, self) end end |