Class: DispatchRider::Registrars::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch-rider/registrars/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



10
11
12
# File 'lib/dispatch-rider/registrars/base.rb', line 10

def initialize
  @store = {}
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



8
9
10
# File 'lib/dispatch-rider/registrars/base.rb', line 8

def store
  @store
end

Instance Method Details

#fetch(name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/dispatch-rider/registrars/base.rb', line 30

def fetch(name)
  begin
    store.fetch(name.to_sym)
  rescue IndexError
    raise NotRegistered.new(name)
  end
end

#register(name, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/dispatch-rider/registrars/base.rb', line 14

def register(name, options = {})
  store[name.to_sym] = value(name, options)
  self
rescue NameError
  raise NotFound.new(name)
end

#unregister(name) ⇒ Object



25
26
27
28
# File 'lib/dispatch-rider/registrars/base.rb', line 25

def unregister(name)
  store.delete(name.to_sym)
  self
end

#value(name, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/dispatch-rider/registrars/base.rb', line 21

def value(name, options = {})
  raise NotImplementedError
end