class Oxidized::Manager
Attributes
Public Class Methods
Source
# File lib/oxidized/manager.rb, line 8 def load(dir, file, namespace) require File.join dir, file + '.rb' # Search the object to load in namespace klass = namespace.constants.find { |const| const.to_s.casecmp(file).zero? } return false unless klass klass = namespace.const_get klass i = klass.new i.setup if i.respond_to? :setup { file => klass } rescue LoadError false end
Source
# File lib/oxidized/manager.rb, line 28 def initialize @input = {} @output = {} @source = {} @model = {} @hook = {} end
Public Instance Methods
Source
# File lib/oxidized/manager.rb, line 52 def add_hook(name) loader @hook, Config::HOOK_DIR, "hook", name, Object end
Source
# File lib/oxidized/manager.rb, line 36 def add_input(name) loader @input, Config::INPUT_DIR, "input", name, Oxidized end
Source
# File lib/oxidized/manager.rb, line 48 def add_model(name) loader @model, Config::MODEL_DIR, "model", name, Object end
Source
# File lib/oxidized/manager.rb, line 40 def add_output(name) loader @output, Config::OUTPUT_DIR, "output", name, Oxidized::Output end
Source
# File lib/oxidized/manager.rb, line 44 def add_source(name) loader @source, Config::SOURCE_DIR, "source", name, Oxidized::Source end
Private Instance Methods
Source
# File lib/oxidized/manager.rb, line 59 def loader(hash, global_dir, local_dir, name, namespace) dir = File.join(Config::ROOT, local_dir) map = Manager.load(dir, name, namespace) if File.exist? File.join(dir, name + ".rb") map ||= Manager.load(global_dir, name, namespace) hash.merge!(map) if map end
if local version of file exists, load it, else load global - return falsy value if nothing loaded