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.



12
13
14
# File 'lib/dispatch-rider/registrars/base.rb', line 12

def initialize
  @store = {}
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



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

def store
  @store
end

Instance Method Details

#fetch(name) ⇒ Object



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

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

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



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

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

#unregister(name) ⇒ Object



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

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

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

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/dispatch-rider/registrars/base.rb', line 23

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