Sha256: a2a09c93d6a65f1e5543891fea0c50299357a4f1283fa6786bf0b695e0da7d25

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveModel
      module NumericalityMatchers
        # @private
        class OddNumberMatcher < NumericTypeMatcher
          NON_ODD_NUMBER_VALUE  = 2

          def initialize(attribute, options = {})
            @attribute = attribute
            @disallow_value_matcher =
              DisallowValueMatcher.new(NON_ODD_NUMBER_VALUE.to_s).
              for(@attribute).
              with_message(:odd)
          end

          def allowed_type
            'odd numbers'
          end

          def diff_to_compare
            2
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoulda-matchers-3.0.0 lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb