class Shoulda::Matchers::ActiveModel::NumericalityMatchers::OddNumberMatcher

@private

Constants

NON_ODD_NUMBER_VALUE

Public Instance Methods

allowed_type_adjective() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb, line 20
def allowed_type_adjective
  'odd'
end
diff_to_compare() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb, line 24
def diff_to_compare
  2
end
simple_description() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb, line 9
def simple_description
  description = ''

  if expects_strict?
    description << 'strictly '
  end

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

Protected Instance Methods

disallowed_value() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb, line 34
def disallowed_value
  if @numeric_type_matcher.given_numeric_column?
    NON_ODD_NUMBER_VALUE
  else
    NON_ODD_NUMBER_VALUE.to_s
  end
end
wrap_disallow_value_matcher(matcher) click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb, line 30
def wrap_disallow_value_matcher(matcher)
  matcher.with_message(:odd)
end