Class: Medicine::Injections Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initializeInjections

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Injections.



6
7
8
# File 'lib/medicine/injections.rb', line 6

def initialize
  @injections = {}
end

Instance Method Details

#[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/medicine/injections.rb', line 16

def [](name)
  @injections[name]
end

#empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


29
30
31
# File 'lib/medicine/injections.rb', line 29

def empty?
  @injections.empty?
end

#fetch(name, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
# File 'lib/medicine/injections.rb', line 10

def fetch(name, &block)
  @injections.fetch(name, &block)
rescue KeyError
  raise ArgumentError, "No dependency with name #{name} has been injected."
end

#include?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


25
26
27
# File 'lib/medicine/injections.rb', line 25

def include?(name)
  @injections.has_key?(name)
end

#set(name, dependency) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
# File 'lib/medicine/injections.rb', line 20

def set(name, dependency)
  warn "#{name} has already been injected" if include?(name)
  @injections[name] = dependency
end