Class: Wirer::Factory::FromInstance
- Inherits:
-
Object
- Object
- Wirer::Factory::FromInstance
- Includes:
- Interface
- Defined in:
- lib/wirer/factory/from_instance.rb
Overview
For when you have some pre-existing instance which you want to wrap as a singleton Factory. (You wouldn’t normally need to do this yourself, but rather Container uses it
under the hood if you add an existing instance to the container)
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#provides_features ⇒ Object
readonly
Returns the value of attribute provides_features.
Instance Method Summary collapse
-
#initialize(instance, *features) ⇒ FromInstance
constructor
A new instance of FromInstance.
- #new_from_dependencies(deps = nil) ⇒ Object
- #provides_class ⇒ Object
Methods included from Interface
#constructor_dependencies, #curry_with_dependencies, #inject_dependency, #post_initialize, #setter_dependencies, #wrapped_with
Constructor Details
#initialize(instance, *features) ⇒ FromInstance
Returns a new instance of FromInstance.
11 12 13 14 |
# File 'lib/wirer/factory/from_instance.rb', line 11 def initialize(instance, *features) @instance = instance @provides_features = features end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
9 10 11 |
# File 'lib/wirer/factory/from_instance.rb', line 9 def instance @instance end |
#provides_features ⇒ Object (readonly)
Returns the value of attribute provides_features.
9 10 11 |
# File 'lib/wirer/factory/from_instance.rb', line 9 def provides_features @provides_features end |
Instance Method Details
#new_from_dependencies(deps = nil) ⇒ Object
20 21 22 |
# File 'lib/wirer/factory/from_instance.rb', line 20 def new_from_dependencies(deps=nil) @instance end |
#provides_class ⇒ Object
16 17 18 |
# File 'lib/wirer/factory/from_instance.rb', line 16 def provides_class @instance.class end |