Sha256: 9a3d4dedfa29d63fed0f6e94b01824c2a937fe21dd842f033d78c9a761ee8e07

Contents?: true

Size: 479 Bytes

Versions: 3

Compression:

Stored size: 479 Bytes

Contents

module Aggro
  module Transform
    # Private: Transforms money representations.
    module Money
      module_function

      def deserialize(value)
        if value.is_a? ::String
          Monetize.parse(value)
        elsif value.is_a? ::Integer
          Monetize.parse(value.to_s)
        elsif value.is_a? ::Money
          value
        end
      end

      def serialize(value)
        value.format with_currency: true if value.is_a? ::Money
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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