# File lib/chef/resource/conditional.rb, line 45 def initialize(positivity, command=nil, command_opts={}, &block) @positivity = positivity case command when String @command, @command_opts = command, command_opts @block = nil when nil raise ArgumentError, "only_if/not_if requires either a command or a block" unless block_given? @command, @command_opts = nil, nil @block = block else raise ArgumentError, "Invalid only_if/not_if command: #{command.inspect} (#{command.class})" end end
# File lib/chef/resource/conditional.rb, line 60 def continue? case @positivity when :only_if evaluate when :not_if !evaluate else raise "Cannot evaluate resource conditional of type #{@positivity}" end end
# File lib/chef/resource/conditional.rb, line 86 def description cmd_or_block = @command ? "command `#{@command}`" : "ruby block" "#{@positivity} #{cmd_or_block}" end
# File lib/chef/resource/conditional.rb, line 71 def evaluate @command ? evaluate_command : evaluate_block end
# File lib/chef/resource/conditional.rb, line 82 def evaluate_block @block.call end
Generated with the Darkfish Rdoc Generator 2.