Sha256: 50605639b19e392e0416f40803fe86ace50a07f23a73ed0dc557454184fc8a8f

Contents?: true

Size: 605 Bytes

Versions: 1

Compression:

Stored size: 605 Bytes

Contents

class BlueprintsBoy::Dependency < BasicObject
  def initialize(name, *args)
    @name = name
    @options = args.extract_options!
    @blueprint_name = args.first || @name
    @registry = []
  end

  def to_proc
    name, options, registry, blueprint_name = @name, @options, @registry, @blueprint_name
    ::Proc.new do
      build blueprint_name => options
      registry.inject(blueprint_data(name)) do |value, (method, args, block)|
        value.send(method, *args, &block)
      end
    end
  end

  def method_missing(method, *args, &block)
    @registry << [method, args, block]
    self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blueprints_boy-1.0.0 lib/blueprints_boy/dependency.rb