Class: Shoulda::Matchers::ActiveModel::NumericalityMatchers::EvenNumberMatcher

Inherits:
NumericTypeMatcher
  • Object
show all
Defined in:
lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb

Constant Summary collapse

NON_EVEN_NUMBER_VALUE =
1

Instance Method Summary collapse

Methods inherited from NumericTypeMatcher

#allowed_type_name, #initialize

Constructor Details

This class inherits a constructor from Shoulda::Matchers::ActiveModel::NumericalityMatchers::NumericTypeMatcher

Instance Method Details

#allowed_type_adjectiveObject



20
21
22
# File 'lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb', line 20

def allowed_type_adjective
  'even'
end

#diff_to_compareObject



24
25
26
# File 'lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb', line 24

def diff_to_compare
  2
end

#simple_descriptionObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb', line 9

def simple_description
  description = ''

  if expects_strict?
    description << 'strictly '
  end

  description +
    "disallow :#{attribute} from being an odd number"
end