Class: Injectable::DependenciesProxy
- Inherits:
-
Object
- Object
- Injectable::DependenciesProxy
- Defined in:
- lib/injectable/dependencies_proxy.rb
Overview
Memoizes the Dependencies generated by Dependency based on DependencyGraph
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#get(name) ⇒ Object
Get the instance of the dependency
name
. -
#initialize(graph:, namespace: nil) ⇒ DependenciesProxy
constructor
A new instance of DependenciesProxy.
Constructor Details
#initialize(graph:, namespace: nil) ⇒ DependenciesProxy
Returns a new instance of DependenciesProxy.
6 7 8 9 10 |
# File 'lib/injectable/dependencies_proxy.rb', line 6 def initialize(graph:, namespace: nil) @graph = graph @namespace = namespace @instances = {} end |
Instance Attribute Details
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
4 5 6 |
# File 'lib/injectable/dependencies_proxy.rb', line 4 def graph @graph end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
4 5 6 |
# File 'lib/injectable/dependencies_proxy.rb', line 4 def namespace @namespace end |
Instance Method Details
#get(name) ⇒ Object
Get the instance of the dependency name
13 14 15 |
# File 'lib/injectable/dependencies_proxy.rb', line 13 def get(name) @instances[name] ||= graph[name].instance(args: memoized_dependencies_of(name), namespace: namespace) end |