Module: Q::Dispatcher

Defined in:
lib/q/dispatcher.rb

Defined Under Namespace

Classes: AdapterNotFoundError, AdapterNotSpecifiedError

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/q/dispatcher.rb', line 17

def [] key
  return dispatchables[key] unless dispatchables[key].nil?
  begin
    require(@require_pattern % key.to_s)
    dispatchables[key] = const_get "#{key.to_s.capitalize}#{@constant_suffix}"
  rescue LoadError
    m = "Unable to find #{key} adapter, make sure it is in your load path"
    raise AdapterNotFoundError, m
  end
end

#constant_suffix(suffix) ⇒ Object



9
10
11
# File 'lib/q/dispatcher.rb', line 9

def constant_suffix suffix
  @constant_suffix = suffix
end

#require_pattern(pattern) ⇒ Object



6
7
8
# File 'lib/q/dispatcher.rb', line 6

def require_pattern pattern
  @require_pattern = pattern
end