Class: DiFtw::Provider
- Inherits:
-
Object
- Object
- DiFtw::Provider
- Defined in:
- lib/diftw/provider.rb
Overview
Class that provides a dependency via a “call” method. It may optionally depend on other dependencies, which will be available as methods inside the given Proc.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the proc and returns the dependency.
-
#initialize(injector, name, y, deps = []) ⇒ Provider
constructor
A new instance of Provider.
Constructor Details
#initialize(injector, name, y, deps = []) ⇒ Provider
Returns a new instance of Provider.
13 14 15 16 |
# File 'lib/diftw/provider.rb', line 13 def initialize(injector, name, y, deps = []) @name, @y = name, y injector.inject_instance self, *deps if deps.any? end |
Instance Method Details
#call ⇒ Object
Executes the proc and returns the dependency
19 20 21 |
# File 'lib/diftw/provider.rb', line 19 def call self.instance_exec(&@y) end |