Class: Wirer::Factory::FromInstance

Inherits:
Object
  • Object
show all
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 Method Summary collapse

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

#instanceObject (readonly)

Returns the value of attribute instance.



9
10
11
# File 'lib/wirer/factory/from_instance.rb', line 9

def instance
  @instance
end

#provides_featuresObject (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_classObject



16
17
18
# File 'lib/wirer/factory/from_instance.rb', line 16

def provides_class
  @instance.class
end