Sha256: 2155ec51dfdf1026770d3c8148319cda0d68206fc0f95cb4bb4dde40028fb9ea

Contents?: true

Size: 874 Bytes

Versions: 20

Compression:

Stored size: 874 Bytes

Contents

require 'scorpion/dependency'

module Scorpion
  class Dependency
    # {Dependency} that delegates to another object that implements
    # #call( scorpion, *args, &block ).
    class BuilderDependency < Scorpion::Dependency

      # ============================================================================
      # @!group Attributes
      #

      # @!attribute
      # @return [#call(scorpion,*args,&block)] the builder to use to fetch instances of the dependency.
        attr_reader :builder

      #
      # @!endgroup Attributes

      def initialize( contract, traits = nil, builder = nil, &block )
        @builder = block_given? ? block : builder
        super contract, traits
      end

      # @see Scorpion::Dependency#fetch
      def fetch( hunt )
        builder.call( hunt, *hunt.arguments, **hunt.dependencies, &hunt.block )
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
scorpion-ioc-0.6.2 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.6.1 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.6.0 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.23 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.22 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.21 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.20 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.19 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.18 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.17 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.16 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.15 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.14 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.13 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.12 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.11 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.10 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.9 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.8 lib/scorpion/dependency/builder_dependency.rb
scorpion-ioc-0.5.7 lib/scorpion/dependency/builder_dependency.rb