Commit 1011ca49 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add a DSL evaluator to QA base factory class

parent 2de8fb7b
require 'forwardable'
module QA
module Factory
class Base
extend SingleForwardable
def_delegators :evaluator, :dependency, :dependencies
def fabricate!(*_args)
raise NotImplementedError
end
......@@ -17,13 +23,21 @@ module QA
end
end
def self.dependencies
@dependencies ||= {}
def self.evaluator
@evaluator ||= Factory::Base::DSL.new(self)
end
def self.dependency(factory, as:, &block)
class DSL
attr_reader :dependencies
def initialize(base)
@base = base
@dependencies = {}
end
def dependency(factory, as:, &block)
as.tap do |name|
class_eval { attr_accessor name }
@base.class_eval { attr_accessor name }
Dependency::Signature.new(factory, block).tap do |signature|
dependencies.store(name, signature)
......@@ -32,4 +46,5 @@ module QA
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment