Class: Contentful::DateCoercion

Inherits:
BaseCoercion show all
Defined in:
lib/contentful/coercions.rb

Overview

Coercion for Date Types

Instance Attribute Summary

Attributes inherited from BaseCoercion

#options, #value

Instance Method Summary collapse

Methods inherited from BaseCoercion

#initialize

Constructor Details

This class inherits a constructor from Contentful::BaseCoercion

Instance Method Details

#coerceObject

Coerces value to DateTime



62
63
64
65
66
67
# File 'lib/contentful/coercions.rb', line 62

def coerce(*)
  return nil if value.nil?
  return value if value.is_a?(Date)

  DateTime.parse(value)
end