Sha256: 53dce12d878596877dc02378c331199739a3ec8bbcc7c5d9d9d2bfc499352e51

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

module Hari
  class Entity
    module Serialization
      module Integer

        def self.serialize(value, options = {})
          desserialize value, options
        end

        def self.desserialize(value, options = {})
          case value
          when ::String
            if value =~ /^\d+$/
              value.to_i
            else
              raise
            end
          else
            Integer(value)
          end
        rescue
          raise SerializationError, "#{options[:name]}:#{value} is not an integer"
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.1 lib/hari/entity/serialization/integer.rb