Module: ActiveModel::AttributeRegistration::ClassMethods
- Defined in:
- activemodel/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 'activemodel/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 'activemodel/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 |