Module: Errgonomic::Rails::ActiveModelAttributeDefault
- Defined in:
- lib/errgonomic/rails/active_record_optional.rb
Overview
A declared default reaches the record's attribute without passing a writer: it is held as given and cast the first time the attribute is read. Unwrapping where it is declared is the only point above the type, and it keeps the stored default a plain value, as an assigned one is.
Instance Method Summary collapse
Instance Method Details
#attribute(name, type = nil, **options) ⇒ Object
759 760 761 762 |
# File 'lib/errgonomic/rails/active_record_optional.rb', line 759 def attribute(name, type = nil, **) [:default] = Errgonomic::Rails.unwrap_option_default([:default]) if .key?(:default) super(name, type, **) end |