Sha256: d0feaaf0f0879655f9d8a98f17ca0d417e7df78107177b39eefc70728977388b

Contents?: true

Size: 465 Bytes

Versions: 18

Compression:

Stored size: 465 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Serialization
    module Type
      class FormatDateType < LedgerSync::Type::Value
        attr_reader :format

        def initialize(args = {})
          @format = args.fetch(:format)

          super()
        end

        def cast_value(args = {})
          value = args.fetch(:value)

          return if value.nil?

          value.to_datetime.strftime(format)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ledger_sync-2.6.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.5.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.4.4 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.3.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.2.3 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.2.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.2.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.0.2 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.0.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.0.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-2.0.0.pre.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.8.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.8.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.7.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.6.0 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.5.2 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.5.1 lib/ledger_sync/serialization/type/format_date_type.rb
ledger_sync-1.5.0 lib/ledger_sync/serialization/type/format_date_type.rb