class Sinatra::Browse::ParameterTypes::DateTime

Public Class Methods

new(name, map) click to toggle source
Calls superclass method Sinatra::Browse::ParameterType::new
# File lib/sinatra/browse/parameter_types/date_time.rb, line 10
def initialize(name, map)
  # Allow strings for min and max values
  map[:min] = coerce(map[:min]) if map[:min].is_a?(::String)
  map[:max] = coerce(map[:max]) if map[:max].is_a?(::String)

  super(name, map)
end

Public Instance Methods

coerce(value) click to toggle source
# File lib/sinatra/browse/parameter_types/date_time.rb, line 18
def coerce(value)
  # We add this line because default values also get coerced.
  return value if value.is_a?(::DateTime)

  ::DateTime.parse(value)
end