Sha256: 37d5a114cfcd4819343a377e2529fdfa5ff82c1a3f66e98d107c738daf058b0e

Contents?: true

Size: 695 Bytes

Versions: 3

Compression:

Stored size: 695 Bytes

Contents

require 'scorpion/prey'

module Scorpion
  class Prey
    # {Prey} for an explicit builder block
    class BuilderPrey < Scorpion::Prey

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

      # @!attribute
      # @return [#call(scorpion)] the builder to use to fetch instances of the prey.
        attr_reader :builder

      #
      # @!endgroup Attributes


      def initialize( contract, traits = nil, &builder )
        @builder = builder
        super
      end

      # @see Scorpion::Prey#fetch
      def fetch( scorpion, *args, &block )
        builder.call( scorpion, *args, &block )
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scorpion-ioc-0.3.0 lib/scorpion/prey/builder_prey.rb
scorpion-ioc-0.2.0 lib/scorpion/prey/builder_prey.rb
scorpion-ioc-0.1.0 lib/scorpion/prey/builder_prey.rb