module Timetrap::Helpers::AutoLoad
Public Instance Methods
auto_load(name, type)
click to toggle source
# File lib/timetrap/helpers.rb, line 12 def auto_load(name, type) err_msg = "Can't load #{name.inspect} #{type}." begin paths = ( Array(Config["#{type}_search_paths"]) + [ File.join( File.dirname(__FILE__), type.pluralize) ] ) if paths.detect do |path| begin fp = File.join(path, name) require File.join(path, name) true rescue LoadError nil end end else raise LoadError, "Couldn't find #{name}.rb in #{paths.inspect}" end namespace = Timetrap.const_get(type.pluralize.camelize) namespace.const_get(name.camelize) rescue LoadError, NameError => e err = e.class.new("#{err_msg} (#{e.message})") err.set_backtrace(e.backtrace) raise err end end
load_auto_sheet(auto_sheet)
click to toggle source
# File lib/timetrap/helpers.rb, line 8 def load_auto_sheet(auto_sheet) auto_load(auto_sheet, 'auto_sheet') end
load_formatter(formatter)
click to toggle source
# File lib/timetrap/helpers.rb, line 4 def load_formatter(formatter) auto_load(formatter, 'formatter') end