Sha256: 580ecc7a64818cdf7ed1a9cf17023513e9d635e1ef0caf6dcc87e7b8c1bb44d9

Contents?: true

Size: 366 Bytes

Versions: 13

Compression:

Stored size: 366 Bytes

Contents

module ApiResource

  module Typecast

    module IntegerTypecaster

      def self.from_api(value)
        return value.to_i if value.respond_to?(:to_i)
        # Special case so that true typecasts to 1
        return 1 if value.class == TrueClass
        return value.to_s.to_i
      end

      def self.to_api(value)
        value
      end

    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
api_resource-0.6.12 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.11 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.9 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.10 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.8 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.7 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.6 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.5 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.4 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.3 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.2 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.1 lib/api_resource/typecasters/integer_typecaster.rb
api_resource-0.6.0 lib/api_resource/typecasters/integer_typecaster.rb