Class: Aequitas::Rule::Value::NotEqual

Inherits:
Aequitas::Rule::Value show all
Defined in:
lib/aequitas/rule/value/not_equal.rb

Instance Attribute Summary

Attributes inherited from Aequitas::Rule

#attribute_name, #custom_message, #guard, #skip_condition

Attributes included from ValueObject

#equalizer

Instance Method Summary collapse

Methods inherited from Aequitas::Rule::Value

#expected, #initialize, rules_for, #valid?

Methods inherited from Aequitas::Rule

#attribute_value, #execute?, #initialize, rules_for, #skip?, #validate, #violation_info, #violation_values

Methods included from ValueObject

#equalize_on

Constructor Details

This class inherits a constructor from Aequitas::Rule::Value

Instance Method Details

#valid_value?(value) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'lib/aequitas/rule/value/not_equal.rb', line 10

def valid_value?(value)
  value != expected
rescue ArgumentError
  # TODO: figure out better solution for: can't compare String with Integer
  true
end

#violation_data(resource) ⇒ Object



21
22
23
# File 'lib/aequitas/rule/value/not_equal.rb', line 21

def violation_data(resource)
  [ [ :not_expected, expected ] ]
end

#violation_type(resource) ⇒ Object



17
18
19
# File 'lib/aequitas/rule/value/not_equal.rb', line 17

def violation_type(resource)
  :not_equal_to
end