Class: Scorpion::Dependency::CapturedDependency
- Inherits:
-
Scorpion::Dependency
- Object
- Scorpion::Dependency
- Scorpion::Dependency::CapturedDependency
- Extended by:
- Forwardable
- Defined in:
- lib/scorpion/dependency/captured_dependency.rb
Attributes collapse
-
#instance ⇒ Object
The instance that was captured.
-
#specific_dependency ⇒ Scorpion::Dependency
writeonly
The actual dependency to hunt.
Attributes inherited from Scorpion::Dependency
Instance Method Summary collapse
- #fetch(hunt) ⇒ Object
-
#initialize(specific_dependency) ⇒ CapturedDependency
constructor
A new instance of CapturedDependency.
- #release ⇒ Object
- #replicate ⇒ Object
Methods inherited from Scorpion::Dependency
#==, define, #hash, #inspect, #satisfies?
Constructor Details
#initialize(specific_dependency) ⇒ CapturedDependency
Returns a new instance of CapturedDependency.
28 29 30 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 28 def initialize( specific_dependency ) @specific_dependency = specific_dependency end |
Instance Attribute Details
#instance ⇒ Object
Returns the instance that was captured.
14 15 16 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 14 def instance @instance end |
#specific_dependency=(value) ⇒ Scorpion::Dependency
Returns the actual dependency to hunt. Used to fetch the single #instance.
19 20 21 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 19 def specific_dependency @specific_dependency end |
Instance Method Details
#fetch(hunt) ⇒ Object
33 34 35 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 33 def fetch( hunt ) @instance ||= specific_dependency.fetch( hunt ) # rubocop:disable Naming/MemoizedInstanceVariableName end |
#release ⇒ Object
38 39 40 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 38 def release @instance = nil end |
#replicate ⇒ Object
43 44 45 |
# File 'lib/scorpion/dependency/captured_dependency.rb', line 43 def replicate dup.tap(&:release) end |