Sha256: b7932f2788093d79f42718376a13f0864837c21d8b63bc76df543c7c987a85cb

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 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,:traits,: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 )
      end

      # @see Dependency#release
      def release
        @instance = nil
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
scorpion-ioc-0.5.16 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.15 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.14 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.13 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.12 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.11 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.10 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.9 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.8 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.7 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.6 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.5 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.4 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.2 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.1 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.5.0 lib/scorpion/dependency/captured_dependency.rb
scorpion-ioc-0.4.0 lib/scorpion/dependency/captured_dependency.rb