aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/attribute_set.rb
Commit message (Collapse)AuthorAgeFilesLines
* Unify _read_attribute definition to use &blockTakashi Kokubun2018-12-201-10/+2
| | | | | | | | Thanks to ko1, passing block parameter to another method is significantly optimized in Ruby 2.5. https://bugs.ruby-lang.org/issues/14045 Thus we no longer need to keep this ugly hack.
* `deep_dup` is used in `AttributeSet#deep_dup`Ryuta Kamizono2018-01-131-0/+1
|
* Change how `AttributeSet::Builder` receives its defaultsSean Griffin2017-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | 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-091-0/+113
Use these to back the attributes API. Stop automatically including ActiveModel::Dirty in ActiveModel::Attributes, and make it optional.