Class: Scorpion::Dependency::BuilderDependency

Inherits:
Scorpion::Dependency show all
Defined in:
lib/scorpion/dependency/builder_dependency.rb

Overview

Scorpion::Dependency that delegates to another object that implements #call( scorpion, *args, &block ).

Attributes collapse

Attributes inherited from Scorpion::Dependency

#contract

Instance Method Summary collapse

Methods inherited from Scorpion::Dependency

#==, define, #hash, #inspect, #release, #replicate, #satisfies?

Constructor Details

#initialize(contract, builder = nil, &block) ⇒ BuilderDependency

Returns a new instance of BuilderDependency.



20
21
22
23
# File 'lib/scorpion/dependency/builder_dependency.rb', line 20

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

Instance Attribute Details

#builder#call(scorpion,*args,&block)

Returns the builder to use to fetch instances of the dependency.

Returns:

  • (#call(scorpion,*args,&block))

    the builder to use to fetch instances of the dependency.



15
16
17
# File 'lib/scorpion/dependency/builder_dependency.rb', line 15

def builder
  @builder
end

Instance Method Details

#fetch(hunt) ⇒ Object



26
27
28
# File 'lib/scorpion/dependency/builder_dependency.rb', line 26

def fetch( hunt )
  builder.call( hunt, *hunt.arguments, &hunt.block )
end