1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/lib/active_model
Sean Griffin 95b86e57a6 Change how AttributeSet::Builder receives its defaults
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.
2017-11-27 14:06:51 -07:00
..
attribute Move Attribute and AttributeSet to ActiveModel 2017-11-09 14:29:39 -05:00
attribute_set Change how AttributeSet::Builder receives its defaults 2017-11-27 14:06:51 -07:00
locale
serializers Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
type [Active Model] require => require_relative 2017-10-21 22:48:27 +09:00
validations Execute ConfirmationValidator validation when _confirmation's value is false 2017-11-05 19:24:49 +00:00
attribute.rb Add missing autoload Type (#31123) 2017-11-11 06:43:54 +09:00
attribute_assignment.rb add frozen string literal comment 2017-06-15 11:45:15 +09:00
attribute_methods.rb Merge pull request #29788 from kamipo/remove_unused_mutex_m 2017-07-17 13:54:37 -04:00
attribute_mutation_tracker.rb Add missing require "active_support/core_ext/hash/indifferent_access" 2017-11-10 23:48:53 +09:00
attribute_set.rb Change how AttributeSet::Builder receives its defaults 2017-11-27 14:06:51 -07:00
attributes.rb Add missing autoload Type (#31123) 2017-11-11 06:43:54 +09:00
callbacks.rb Use tt in doc for ActiveRecord [ci skip] 2017-08-27 14:01:29 +09:00
conversion.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
dirty.rb Fix "warning: instance variable @attributes not initialized" 2017-11-10 14:02:28 +09:00
errors.rb fix bug on added? method 2017-11-13 17:27:47 +01:00
forbidden_attributes_protection.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
gem_version.rb Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
lint.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
model.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
naming.rb Clarify intentions around method redefinitions 2017-09-01 14:27:13 +09:30
railtie.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
secure_password.rb Talk about bytes not characters 2017-07-31 17:42:43 -04:00
serialization.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
translation.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
type.rb Move Attribute and AttributeSet to ActiveModel 2017-11-09 14:29:39 -05:00
validations.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
validator.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
version.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00