Class: Parameters::Types::DateTime Private

Inherits:
Date show all
Defined in:
lib/parameters/types/date_time.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Class Method Summary collapse

Methods inherited from Object

#===, ===, to_ruby

Methods inherited from Type

#<, #<=, #==, ===, #===, #coerce, #to_ruby, to_ruby

Class Method Details

.coerce(value) ⇒ ::DateTime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerces a value into a DateTime object.

Parameters:

  • value (#to_datetime, ::String)

    The value to coerce.

Returns:

  • (::DateTime)

    The coerced DateTime.

Since:

  • 0.3.0



19
20
21
22
23
24
25
# File 'lib/parameters/types/date_time.rb', line 19

def self.coerce(value)
  if value.respond_to?(:to_datetime)
    value.to_datetime
  else
    ::DateTime.parse(value.to_s)
  end
end