Sha256: 648739cb2b0838d64810130b92d502e74f5234e3bbac04631c762662260425f4

Contents?: true

Size: 309 Bytes

Versions: 7

Compression:

Stored size: 309 Bytes

Contents

module Gummi
  module Fields
    class PositiveInteger < Virtus::Attribute

      def coerce(value)
        coerced = value.to_i
        if coerced > 0
          coerced
        else
          default_value.value
        end
      end

      def mapping
        { type: 'integer' }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gummi-0.1.2 lib/gummi/fields/positive_integer.rb
gummi-0.1.1 lib/gummi/fields/positive_integer.rb
gummi-0.1.0 lib/gummi/fields/positive_integer.rb
gummi-0.0.9 lib/gummi/fields/positive_integer.rb
gummi-0.0.8 lib/gummi/fields/positive_integer.rb
gummi-0.0.7 lib/gummi/fields/positive_integer.rb
gummi-0.0.6 lib/gummi/fields/positive_integer.rb