Parent

Class/Module Index [+]

Quicksearch

Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher

@private

Attributes

diff_to_compare[R]

Public Class Methods

new(attribute) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 289
def initialize(attribute)
  @attribute = attribute
  @submatchers = []
  @diff_to_compare = DEFAULT_DIFF_TO_COMPARE
  add_disallow_value_matcher
end

Public Instance Methods

allow_nil() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 303
def allow_nil
  prepare_submatcher(
    AllowValueMatcher.new(nil)
      .for(@attribute)
      .with_message(:not_a_number)
  )
  self
end
description() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 361
def description
  "only allow #{allowed_types} for #{@attribute}#{comparison_descriptions}"
end
even() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 319
def even
  prepare_submatcher(
    NumericalityMatchers::EvenNumberMatcher.new(@attribute)
  )
  self
end
failure_message() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 365
def failure_message
  submatcher_failure_messages_for_should.last
end
Also aliased as: failure_message_for_should
failure_message_for_should() click to toggle source
Alias for: failure_message
failure_message_for_should_not() click to toggle source
failure_message_when_negated() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 370
def failure_message_when_negated
  submatcher_failure_messages_for_should_not.last
end
is_equal_to(value) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 336
def is_equal_to(value)
  prepare_submatcher(comparison_matcher_for(value, :==).for(@attribute))
  self
end
is_greater_than(value) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 326
def is_greater_than(value)
  prepare_submatcher(comparison_matcher_for(value, :>).for(@attribute))
  self
end
is_greater_than_or_equal_to(value) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 331
def is_greater_than_or_equal_to(value)
  prepare_submatcher(comparison_matcher_for(value, :>=).for(@attribute))
  self
end
is_less_than(value) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 341
def is_less_than(value)
  prepare_submatcher(comparison_matcher_for(value, :<).for(@attribute))
  self
end
is_less_than_or_equal_to(value) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 346
def is_less_than_or_equal_to(value)
  prepare_submatcher(comparison_matcher_for(value, :<=).for(@attribute))
  self
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 356
def matches?(subject)
  @subject = subject
  submatchers_match?
end
odd() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 312
def odd
  prepare_submatcher(
    NumericalityMatchers::OddNumberMatcher.new(@attribute)
  )
  self
end
only_integer() click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 296
def only_integer
  prepare_submatcher(
    NumericalityMatchers::OnlyIntegerMatcher.new(@attribute)
  )
  self
end
with_message(message) click to toggle source
# File lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb, line 351
def with_message(message)
  @submatchers.each { |matcher| matcher.with_message(message) }
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.