Class: Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher
- Defined in:
- lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
Constant Summary
- NON_NUMERIC_VALUE =
'abcd'
Instance Method Summary (collapse)
- - (Object) description
- - (Object) even
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
-
- (ValidateNumericalityOfMatcher) initialize(attribute)
constructor
A new instance of ValidateNumericalityOfMatcher.
- - (Boolean) matches?(subject)
- - (Object) odd
- - (Object) only_integer
- - (Object) with_message(message)
Constructor Details
- (ValidateNumericalityOfMatcher) initialize(attribute)
A new instance of ValidateNumericalityOfMatcher
27 28 29 30 31 32 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 27 def initialize(attribute) @attribute = attribute @submatchers = [] add_disallow_value_matcher end |
Instance Method Details
- (Object) description
62 63 64 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 62 def description "only allow #{allowed_types} values for #{@attribute}" end |
- (Object) even
46 47 48 49 50 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 46 def even even_number_matcher = OddEvenNumberMatcher.new(@attribute, :even => true) add_submatcher(even_number_matcher) self end |
- (Object) failure_message_for_should
66 67 68 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 66 def .last end |
- (Object) failure_message_for_should_not
70 71 72 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 70 def .last end |
- (Boolean) matches?(subject)
57 58 59 60 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 57 def matches?(subject) @subject = subject submatchers_match? end |
- (Object) odd
40 41 42 43 44 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 40 def odd odd_number_matcher = OddEvenNumberMatcher.new(@attribute, :odd => true) add_submatcher(odd_number_matcher) self end |
- (Object) only_integer
34 35 36 37 38 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 34 def only_integer only_integer_matcher = OnlyIntegerMatcher.new(@attribute) add_submatcher(only_integer_matcher) self end |
- (Object) with_message(message)
52 53 54 55 |
# File 'lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb', line 52 def () @submatchers.each { |matcher| matcher.() } self end |