class Opi::Loader

Public Class Methods

funkyload(file) click to toggle source
# File lib/opi/loader.rb, line 10
def funkyload(file)
  begin
    if cache = loadcache[file]
      return if ENV['RACK_ENV'] == 'production'

      if (mtime = File.mtime(file)) > cache
        puts "[Opi::Loader]".green + " reloading: #{file}"
        load file
        loadcache[file] = mtime
      end
    else
      puts "[Opi::Loader]".green + " loading: #{file}"
      load file
      loadcache[file] = File.mtime(file)
    end
  rescue Exception => e
    puts "[Opi::Loader] Exception loading class [#{file}]: #{e.message}"
    puts e.backtrace.join("\n")
    raise e
  end
end
loadcache() click to toggle source
# File lib/opi/loader.rb, line 6
def loadcache()
  @loadcache ||= {}
end
reload!() click to toggle source
# File lib/opi/loader.rb, line 32
def reload!
  Dir["#{@prefix}app/**/*.rb"].each { |x| funkyload x }
end