Refactor action arguments checks

This commit is contained in:
Thibault Jouan
2014-10-09 19:54:32 +00:00
parent 5549ebc676
commit 7bdb778159
3 changed files with 8 additions and 8 deletions

View File

@@ -3,10 +3,7 @@ module Producer
module Actions
class FileAppend < Action
def setup
if arguments.compact.size != 2
fail ArgumentError, '`%s\' action requires 2 arguments' % name
end
check_arguments_size! 2
@path, @content = arguments
end

View File

@@ -3,10 +3,7 @@ module Producer
module Actions
class FileWriter < Action
def setup
if arguments.compact.size != 2
fail ArgumentError, '`%s\' action requires 2 arguments' % name
end
check_arguments_size! 2
@path, @content = arguments
@options[:permissions] = @options.delete :mode if options.key? :mode
@options[:owner] = @options.delete :user if options.key? :user