Class: Container

Inherits:
Object
  • Object
show all
Defined in:
lib/container.rb

Defined Under Namespace

Classes: KeyNotFoundError

Instance Method Summary collapse

Constructor Details

#initializeContainer

Returns a new instance of Container.



11
12
13
# File 'lib/container.rb', line 11

def initialize
  @data = {}
end

Instance Method Details

#register(key, value) ⇒ Object



21
22
23
# File 'lib/container.rb', line 21

def register(key, value)
  @data[key] = value
end

#resolve(key) ⇒ Object



15
16
17
18
19
# File 'lib/container.rb', line 15

def resolve(key)
  @data.fetch(key)
rescue ::KeyError
  raise KeyNotFoundError.new(key)
end