Class: Medicine::Injections Private
- Inherits:
-
Object
- Object
- Medicine::Injections
- 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
- #[](name) ⇒ Object private
- #empty? ⇒ Boolean private
- #fetch(name, &block) ⇒ Object private
- #include?(name) ⇒ Boolean private
-
#initialize ⇒ Injections
constructor
private
A new instance of Injections.
- #set(name, dependency) ⇒ Object private
Constructor Details
#initialize ⇒ Injections
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.
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.
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 |