Sha256: 1c9d270de9b1872ca71055fd14004d66554a3d942139f436403a5dbec6b84591

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

class RestModel
  module Serialization
    class Integer
      def self.serialize(value)
        case value
        when String
          if value =~ /^\d+$/
            value.to_i
          else
            raise
          end
        else
          Integer(value)
        end
      rescue
        raise SerializationError, "value '#{value}' is not an integer"
      end

      def self.desserialize(value)
        serialize(value)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest_model-0.1.18 lib/rest_model/serialization/integer.rb