Module: ActiveModel::AttributeRegistration::ClassMethods
- Defined in:
- lib/active_model/attribute_registration.rb
Overview
:nodoc:
Defined Under Namespace
Classes: PendingAttribute
Instance Method Summary collapse
-
#_default_attributes ⇒ Object
:nodoc:.
- #attribute(name, type = nil, default: (no_default = true), **options) ⇒ Object
-
#attribute_types ⇒ Object
:nodoc:.
Instance Method Details
#_default_attributes ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/active_model/attribute_registration.rb', line 22 def _default_attributes # :nodoc: @default_attributes ||= build_default_attributes end |
#attribute(name, type = nil, default: (no_default = true), **options) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/active_model/attribute_registration.rb', line 12 def attribute(name, type = nil, default: (no_default = true), **) type = resolve_type_name(type, **) if type.is_a?(Symbol) pending = pending_attribute(name) pending.type = type if type pending.default = default unless no_default reset_default_attributes end |
#attribute_types ⇒ Object
:nodoc:
26 27 28 29 30 |
# File 'lib/active_model/attribute_registration.rb', line 26 def attribute_types # :nodoc: @attribute_types ||= _default_attributes.cast_types.tap do |hash| hash.default = Type.default_value end end |