Improve Condition DSL framework:
Add the necessary API so that we can implement new tests easily as new standalone classes. In Condition::DSL: * Add #tests accessor; * Modify constructor so that it accepts the env; * Implement .define_test(keyword, class) method.
This commit is contained in:
@@ -4,13 +4,23 @@ module Producer
|
||||
class DSL
|
||||
class << self
|
||||
def evaluate(env, &block)
|
||||
dsl = new(&block)
|
||||
dsl = new(env, &block)
|
||||
Condition.new(dsl.evaluate)
|
||||
end
|
||||
|
||||
def define_test(keyword, klass)
|
||||
define_method(keyword) do |*args|
|
||||
@tests << klass.new(@env, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(&block)
|
||||
@block = block
|
||||
attr_accessor :tests
|
||||
|
||||
def initialize(env, &block)
|
||||
@env = env
|
||||
@block = block
|
||||
@tests = []
|
||||
end
|
||||
|
||||
def evaluate
|
||||
|
Reference in New Issue
Block a user