def attribute_match?(attribute, value)
      hash_obj_matcher = lambda do |obj, k, v|
        value = obj.send(k)
        if !value.nil? && v.is_a?(Hash)
          v.all? { |k2,v2| hash_obj_matcher.call(value, k2, v2) }
        else
          value == v
        end
      end

      hash_obj_matcher.call(self, attribute, value)
    end
def attribute_match?(attribute, value)
      hash_obj_matcher = lambda do |obj, k, v|
        value = obj.send(k)
        if !value.nil? && v.is_a?(Hash)
          v.all? { |k2,v2| hash_obj_matcher.call(value, k2, v2) }
        else
          value == v
        end
      end

      hash_obj_matcher.call(self, attribute, value)
    end
checks if the square matches the attributes passed.

 @param [Symbol] attribute
   the square's attribute.

 @param [Object,Hash] value
   a value to match on. Can be a hash of attribute/value pairs for deep matching

 ==== Example:
   # Check if square has a piece owned by player 1
   square.attribute_match?(:piece, player_number: 1)