Implement tasks condition feature
This commit is contained in:
1 parent
16134bf827
commit
d146566411
3 files changed
+70
-6
No files matched your search
@@ -9,7 +9,21 @@ module Producer
|
||||
end
|
||||
|
||||
def evaluate
|
||||
instance_eval &@block
|
||||
DSL.new &@block
|
||||
end
|
||||
|
||||
|
||||
class DSL
|
||||
ConditionNotMetError = Class.new(RuntimeError)
|
||||
|
||||
def initialize(&block)
|
||||
instance_eval &block
|
||||
rescue ConditionNotMetError
|
||||
end
|
||||
|
||||
def condition(&block)
|
||||
raise ConditionNotMetError unless block.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user