Sha256: fc5a0751857c64040fae8c160fe8f83d5e0aa4c7f795e47e4c10fbccab870063

Contents?: true

Size: 483 Bytes

Versions: 24

Compression:

Stored size: 483 Bytes

Contents

module JSONAPIonify::Types
  class IntegerType < BaseType

    def sample(*)
      rand(1..123)
    end

    loader do |value|
      raise LoadError, 'input value was not an integer' unless value.is_a?(Fixnum)
      value
    end

    dumper do |value|
      raise DumpError, 'cannot convert value to integer' unless value.respond_to?(:to_i)
      value.to_i.tap do |int|
        raise DumpError, 'output value was not a integer' unless int.is_a? Fixnum
      end
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
jsonapionify-0.12.10 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.9 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.8 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.7 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.5 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.4 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.3 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.2 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.1 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.12.0 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.11 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.10 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.9 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.8 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.7 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.6 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.5 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.11.0 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.10.2 lib/jsonapionify/types/integer_type.rb
jsonapionify-0.10.1 lib/jsonapionify/types/integer_type.rb