lib/sensu/utilities.rb
# Determine if all attribute values match those of the
# corresponding object attributes. Attributes match if the value
# objects are equivalent, are both hashes with matching key/value
# pairs (recursive), have equal string values, or evaluate to true
# (Ruby eval).
#
# @param object [Hash]
# @param match_attributes [Object]
# @param support_eval [TrueClass, FalseClass]
# @param object_attributes [Object]
# @return [TrueClass, FalseClass]
Determine if all attribute values match those of the
corresponding object attributes. Attributes match if the value
objects are equivalent, are both hashes with matching key/value
pairs (recursive), have equal string values, or evaluate to true
(Ruby eval).
Determine if all attribute values match those of the corresponding object attributes . Attributes match if the value objects are equivalent are both hashes with matching key / value pairs ( recursive ) have equal string values or evaluate to true ( Ruby eval ) .
def attributes_match?(object, match_attributes, support_eval=true, object_attributes=nil)
      object_attributes ||= object
      match_attributes.all? do |key, value_one|
        value_two = object_attributes[key]
        case
        when value_one == value_two
          true
        when value_one.is_a?(Hash) && value_two.is_a?(Hash)
          attributes_match?(object, value_one, support_eval, value_two)
        when value_one.to_s == value_two.to_s
          true
        when value_one.is_a?(String) && value_one.start_with?(EVAL_PREFIX) && support_eval
          eval_attribute_value(object, value_one, value_two)
        else
          false
        end
      end
    end
def attributes_match? ( object , match_attributes , support_eval = true , object_attributes = nil ) object_attributes ||= object match_attributes . all? do | key , value_one | value_two = object_attributes [ key ] case when value_one == value_two true when value_one . is_a? ( Hash ) && value_two . is_a? ( Hash ) attributes_match? ( object , value_one , support_eval , value_two ) when value_one . to_s == value_two . to_s true when value_one . is_a? ( String ) && value_one . start_with? ( EVAL_PREFIX ) && support_eval eval_attribute_value ( object , value_one , value_two ) else false end end end
Determine if all attribute values match those of the
corresponding object attributes.
Determine if all attribute values match those of the corresponding object attributes .
None
TrueClass, FalseClass
object
match_attributes
support_eval
object_attributes
None