Sha256: 4201ccfff277c894671df607e49f47b0ffc35a4f8de4edaa08dc89f8c05f7ad1
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
require "scorpion/dependency" module Scorpion class Dependency class CapturedDependency < Scorpion::Dependency extend Forwardable # ============================================================================ # @!group Attributes # # @!attribute # @return [Object] the instance that was captured. attr_reader :instance # @!attribute # @return [Scorpion::Dependency] the actual dependency to hunt. Used to fetch the # single {#instance}. attr_reader :specific_dependency private :specific_dependency delegate [ :contract, :satisfies? ] => :specific_dependency # # @!endgroup Attributes def initialize( specific_dependency ) @specific_dependency = specific_dependency end # @see Dependency#fetch def fetch( hunt ) @instance ||= specific_dependency.fetch( hunt ) # rubocop:disable Naming/MemoizedInstanceVariableName end # @see Dependency#release def release @instance = nil end # @see Dependency#replicate def replicate dup.tap(&:release) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems