aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/attribute_set
Commit message (Collapse)AuthorAgeFilesLines
* Change how `AttributeSet::Builder` receives its defaultsSean Griffin2017-11-271-14/+14
| | | | | | | | | | | | | | | | | | | | | There are two concerns which are both being combined into one here, but both have the same goal. There are certain attributes which we want to always consider initialized. Previously, they were handled separately. The primary key (which is assumed to be backed by a database column) needs to be initialized, because there is a ton of code in Active Record that assumes `foo.id` will never raise. Additionally, we want attributes which aren't backed by a database column to always be initialized, since we would never receive a database value for them. Ultimately these two concerns can be combined into one. The old implementation hid a lot of inherent complexity, and is hard to optimize from the outside. We can simplify things significantly by just passing in a hash. This has slightly different semantics from the old behavior, in that `Foo.select(:bar).first.id` will return the default value for the primary key, rather than `nil` unconditionally -- however, the default value is always `nil` in practice.
* Move Attribute and AttributeSet to ActiveModelLisa Ugray2017-11-092-0/+165
Use these to back the attributes API. Stop automatically including ActiveModel::Dirty in ActiveModel::Attributes, and make it optional.