Method: Arrow::Dispatcher.instance
- Defined in:
- lib/arrow/dispatcher.rb
.instance(key = :__default__) ⇒ Object
Get the instance of the Dispatcher set up under the given key
, which can either be a Symbol or a String containing the path to a configfile. If no key is given, it defaults to :__default__, which is the key assigned when .create is given just a configfile argument.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/arrow/dispatcher.rb', line 89 def self::instance( key=:__default__ ) rval = nil # Fetch the instance which corresponds to the given key if key.is_a?( Symbol ) Arrow::Logger.debug "Returning instance for key %p (one of %p): %p" % [key, @@Instance.keys, @@Instance[key]] rval = @@Instance[ key ] else Arrow::Logger.debug "Returning instance for configfile %p" % [key] configfile = File.( key ) self.create( configfile ) rval = @@Instance[ configfile ] end # Return either a configured Dispatcher instance or a FallbackHandler if # no Dispatcher corresponds to the given key. return rval || Arrow::FallbackHandler.new( key, @@Instance ) end |