Module: ConstCache

Defined in:
lib/motion/const_cache.rb

Class Method Summary collapse

Class Method Details

.cacheObject



4
5
6
# File 'lib/motion/const_cache.rb', line 4

def cache
  @cache ||= Hash.new { |h, k| h[k] = {} }
end

.dumpObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/motion/const_cache.rb', line 8

def dump
  return unless File.exist?(NSBundle.mainBundle.objectForInfoDictionaryKey('APP_ROOT'))
  
  File.open("#{NSBundle.mainBundle.objectForInfoDictionaryKey('APP_ROOT')}/app/_const_cache.rb", 'w') do |file|
    file.puts "# This file was auto-generated. All changes will be overwritten!"
    file.puts
    cache.each do |namespace, hash|
      hash.each do |const_name, const|
        file.puts "ConstCache.cache[#{namespace.inspect}][#{const_name.inspect}] = lambda { #{namespace}::#{const_name} }"
      end
    end
  end
end