Refactor with Forwardable module

This commit is contained in:
Thibault Jouan
2014-11-17 21:44:15 +00:00
parent af1bb97287
commit 86a84bbe12
5 changed files with 15 additions and 32 deletions

View File

@@ -2,9 +2,9 @@ module Producer
module Core
module Tests
class ConditionTest < Test
def verify
condition.met?
end
extend Forwardable
def_delegator :@arguments, :first, :condition_block
def_delegator :condition, :met?, :verify
def condition
Condition.evaluate(env, *condition_args, &condition_block)
@@ -13,10 +13,6 @@ module Producer
def condition_args
arguments.drop 1
end
def condition_block
arguments.first
end
end
end
end

View File

@@ -2,16 +2,15 @@ module Producer
module Core
module Tests
class ShellCommandStatus < Test
extend Forwardable
def_delegator :@arguments, :first, :command
def verify
remote.execute(command)
true
rescue RemoteCommandExecutionError
false
end
def command
arguments.first
end
end
end
end