Sha256: 36e36ef4253867ad125930946be55ccd1766faf6e0981d360c73fed4228a905b

Contents?: true

Size: 333 Bytes

Versions: 1

Compression:

Stored size: 333 Bytes

Contents

module Superstore
  module Types
    class DateType < Base
      FORMAT = '%Y-%m-%d'

      def serialize(value)
        value.strftime(FORMAT) if value
      end

      def deserialize(str)
        Date.strptime(str, FORMAT) if str
      end

      def cast_value(value)
        value.to_date rescue nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-3.0.0 lib/superstore/types/date_type.rb