Class: ActiveModel::Type::Date
- Includes:
- Helpers::Timezone
- Defined in:
- activemodel/lib/active_model/type/date.rb
Overview
Attribute type for date representation. It is registered under the :date
key.
class Person
include ActiveModel::Attributes
attribute :birthday, :date
end
person = Person.new
person.birthday = "1989-07-13"
person.birthday.class # => Date
person.birthday.year # => 1989
person.birthday.month # => 7
person.birthday.day # => 13
String values are parsed using the ISO 8601 date format. Any other values are cast using their to_date
method, if it exists.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
Methods included from Helpers::Timezone
Methods inherited from Value
#==, #as_json, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #immutable_value, #initialize, #map, #serializable?, #serialize, #value_constructed_by_mass_assignment?
Constructor Details
This class inherits a constructor from ActiveModel::Type::Value