class Typero::DateType

Public Instance Methods

db_schema() click to toggle source
# File lib/typero/type/types/date_type.rb, line 18
def db_schema
  [:date, {}]
end
set() click to toggle source
# File lib/typero/type/types/date_type.rb, line 8
def set
  unless [Date].include?(value.class)
    value { |data| DateTime.parse(data) }
  end

  value { |data| DateTime.new(data.year, data.month, data.day) }

  check_date_min_max
end

Private Instance Methods

check_date_min_max() click to toggle source
# File lib/typero/type/types/date_type.rb, line 24
def check_date_min_max
  if min = opts[:min]
    min = DateTime.parse(min)
    error_for(:min_date, min) % min if min > value
  end

  if max = opts[:max]
    max = DateTime.parse(max)
    error_for(:max_date, max) % max if value > max
  end

  value
end