class Formulario::Field::Date

Private Class Methods

allowed_keys() click to toggle source
# File lib/formulario/fields/date.rb, line 11
def self.allowed_keys
  %i[ year month day ]
end
base_class() click to toggle source
# File lib/formulario/fields/date.rb, line 7
def self.base_class
  ::Date
end
parse_hash(hash) click to toggle source
# File lib/formulario/fields/date.rb, line 15
def self.parse_hash(hash)
  return invalid_keys_exceptional_value(hash) if has_invalid_keys?(hash)

  now = ::Date.today
  new ::Date.new(
    hash[:year]  || now.year,
    hash[:month] || now.month,
    hash[:day]   || now.day,
  )
end