Class: Chef::Attribute::Validator::Check::Proc

Inherits:
Chef::Attribute::Validator::Check show all
Defined in:
lib/chef-attribute-validator/checks/proc.rb

Instance Attribute Summary

Attributes inherited from Chef::Attribute::Validator::Check

#check_arg, #path_spec, #rule_name

Instance Method Summary collapse

Methods inherited from Chef::Attribute::Validator::Check

#initialize, list_check_types, make

Constructor Details

This class inherits a constructor from Chef::Attribute::Validator::Check

Instance Method Details

#check(attrset) ⇒ Object



18
19
20
# File 'lib/chef-attribute-validator/checks/proc.rb', line 18

def check(attrset)
  check_arg.call(rule_name, attrset)
end

#validate_check_argObject



9
10
11
12
13
14
15
16
# File 'lib/chef-attribute-validator/checks/proc.rb', line 9

def validate_check_arg
  unless check_arg.kind_of?(::Proc)
    raise "Bad 'proc' check argument '#{check_arg}' for rule '#{rule_name}' - expected a Proc"
  end
  unless check_arg.arity == 2
    raise "Bad 'proc' check argument '#{check_arg}' for rule '#{rule_name}' - Proc must take exactly two arguments, a rule name and an AttributeSet."
  end
end