Class: SmartCore::Injection::Locator::Dependency Private
- Inherits:
-
Object
- Object
- SmartCore::Injection::Locator::Dependency
- Defined in:
- lib/smart_core/injection/locator/dependency.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #bind(&block) ⇒ Any
- #initialize(memoize:) ⇒ void constructor private
- #rebind(&block) ⇒ Any private
Constructor Details
#initialize(memoize:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 |
# File 'lib/smart_core/injection/locator/dependency.rb', line 13 def initialize(memoize:) @binded = false @value = nil @memoize = memoize @barrier = SmartCore::Engine::Lock.new end |
Instance Method Details
#bind(&block) ⇒ Any
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/smart_core/injection/locator/dependency.rb', line 38 def bind(&block) do # NOTE: # Temporary disabled old variant of dependency resolving # cuz we need to reivew the canonical way of dependency resolving # and rework the resolving at all on runtime level (under `memoize: true` option). # Old code variant: # # if @binded # @value # else # @binded = true # @value = yield # end if @memoize if @binded @value else @binded = true @value = yield end else yield end end end |
#rebind(&block) ⇒ Any
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 |
# File 'lib/smart_core/injection/locator/dependency.rb', line 25 def rebind(&block) do @binded = false bind(&block) end end |