Sha256: 8afdb35231d54cb1d2e3823f97c88e03d297e2e7781215286e59b754ad3fa6cf

Contents?: true

Size: 482 Bytes

Versions: 3

Compression:

Stored size: 482 Bytes

Contents

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

      def deserialize(value)
        if value.is_a? ::String
          ::TimeInterval.parse(value)
        elsif interval? value
          value
        end
      end

      def interval?(value)
        value.class.parents.include? ::TimeInterval
      end

      def serialize(value)
        value.iso8601 if interval? value
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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