Sha256: 0fdd6ca10a3052b3684a92013f5b6e2b6c503f4bce34289385d7afc8da3606e1

Contents?: true

Size: 407 Bytes

Versions: 3

Compression:

Stored size: 407 Bytes

Contents

module Aggro
  module Transform
    # Private: Transforms integer representations.
    module Integer
      module_function

      def deserialize(value)
        if value.is_a?(::String)
          string = value.gsub(/[^\d\.]/, '')

          string == '' ? nil : string.to_i
        else
          value.to_i
        end
      end

      def serialize(value)
        value.to_i
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/transform/integer.rb
aggro-0.0.3 lib/aggro/transform/integer.rb
aggro-0.0.2 lib/aggro/transform/integer.rb