class Dynamoid::Dumping::DateDumper

date -> integer/string

Public Instance Methods

process(value) click to toggle source
# File lib/dynamoid/dumping.rb, line 239
def process(value)
  !value.nil? ? format_date(value, @options) : nil
end

Private Instance Methods

format_date(value, options) click to toggle source
# File lib/dynamoid/dumping.rb, line 245
def format_date(value, options)
  use_string_format = if options[:store_as_string].nil?
                        Dynamoid.config.store_date_as_string
                      else
                        options[:store_as_string]
                      end

  if use_string_format
    value.to_date.iso8601
  else
    (value.to_date - Dynamoid::Persistence::UNIX_EPOCH_DATE).to_i
  end
end