2013-07-30 15:57:03 +00:00

31 lines
527 B
Ruby

module Producer
module Core
class Task
attr_reader :name
def initialize(name, &block)
@name = name
@block = block
end
def evaluate
DSL.new &@block
end
class DSL
ConditionNotMetError = Class.new(StandardError)
def initialize(&block)
instance_eval &block
rescue ConditionNotMetError
end
def condition(&block)
raise ConditionNotMetError unless block.call
end
end
end
end
end