Sha256: 4bc1695ee4abb96f510e83a7d37988374ccab1a0fde68286b95ed9cf69cb9cbe

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

require 'scorpion/prey'

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

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

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

      #
      # @!endgroup Attributes

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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scorpion-ioc-0.3.1 lib/scorpion/prey/builder_prey.rb