Module: Object

Defined in:
lib/motion/const_cache.rb

Class Method Summary collapse

Class Method Details

.const_get_with_cache(const, inherit = true) ⇒ Object Also known as: const_get



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/motion/const_cache.rb', line 24

def self.const_get_with_cache(const, inherit = true)
  return const_get_without_cache(const, false) unless inherit
  
  if result = ConstCache.cache[self.name][const]
    result.call
  else
    ConstCache.cache[self.name][const] = lambda { const_get_without_cache(const, true) }

    ConstCache.dump if Object.const_defined?(:RUBYMOTION_ENV) && RUBYMOTION_ENV == 'development'

    ConstCache.cache[self.name][const].call
  end
end