Class: Aliyun::Log::Record::TypeCasting::DateType

Inherits:
Value
  • Object
show all
Defined in:
lib/aliyun/log/record/type_casting.rb

Instance Method Summary collapse

Methods inherited from Value

#initialize

Constructor Details

This class inherits a constructor from Aliyun::Log::Record::TypeCasting::Value

Instance Method Details

#cast(value) ⇒ Object



61
62
63
64
65
# File 'lib/aliyun/log/record/type_casting.rb', line 61

def cast(value)
  return nil unless value.respond_to?(:to_date)

  value.to_date
end

#dump(value) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/aliyun/log/record/type_casting.rb', line 67

def dump(value)
  if value.respond_to?(:to_date)
    value.to_date.to_s
  else
    value.to_s
  end
end