Refactor task DSL usages:
Remove most of task evaluation code from Task class, rely on Task::DSL.evaluate to get an evaluated task. * Task: remove #evaluate, change constructor prototype to accept actions instead of a block, implement .evaluate(name, env &block); * Implement Task::DSL.evaluate method; * Recipe::DSL: remove tasks evaluation from#evaluate, modify #task to use Task.evaluate to return the new task to be rigstered.
This commit is contained in:
@@ -3,16 +3,13 @@ module Producer
|
||||
class Task
|
||||
attr_reader :name, :actions
|
||||
|
||||
def initialize(name, &block)
|
||||
@name = name
|
||||
@block = block
|
||||
@actions = []
|
||||
def self.evaluate(name, env, &block)
|
||||
DSL::evaluate(name, env, &block)
|
||||
end
|
||||
|
||||
def evaluate(env)
|
||||
dsl = DSL.new(&@block)
|
||||
dsl.evaluate(env)
|
||||
@actions = dsl.actions
|
||||
def initialize(name, actions = [])
|
||||
@name = name
|
||||
@actions = actions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user