aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_set.rb
Commit message (Collapse)AuthorAgeFilesLines
* `update_column` take ruby-land input, not database-land inputSean Griffin2014-12-161-0/+4
| | | | | | | | | | | | | | | In the case of serialized columns, we would expect the unserialized value as input, not the serialized value. The original issue which made this distinction, #14163, introduced a bug. If you passed serialized input to the method, it would double serialize when it was sent to the database. You would see the wrong input upon reloading, or get an error if you had a specific type on the serialized column. To put it another way, `update_column` is a special case of `update_all`, which would take `['a']` and not `['a'].to_yaml`, but you would not pass data from `params` to it. Fixes #18037
* Improve the performance of reading attributesSean Griffin2014-11-181-2/+2
| | | | | | | We added a comparison to "id", and call to `self.class.primary_key` a *lot*. We also have performance hits from `&block` all over the place. We skip the check in a new method, in order to avoid breaking the behavior of `read_attribute`
* Reduce the amount of work performed when instantiating AR modelsSean Griffin2014-11-141-9/+5
| | | | | | | | | | We don't know which attributes will or won't be used, and we don't want to create massive bottlenecks at instantiation. Rather than doing *any* iteration over types and values, we can lazily instantiate the object. The lazy attribute hash should not fully implement hash, or subclass hash at any point in the future. It is not meant to be a replacement, but instead implement its own interface which happens to overlap.
* AttributeSet#include? -> AttributeSet#key?Sean Griffin2014-07-111-3/+3
| | | | https://github.com/rails/rails/pull/15868/files#r14135210
* Merge pull request #16015 from sgrif/sg-ensure-initializedRafael Mendonça França2014-07-021-0/+6
|\ | | | | | | | | | | | | Move pk initialization logic onto `AttributeSet` Conflicts: activerecord/lib/active_record/attribute_set.rb
| * Move pk initialization logic onto `AttributeSet`Sean Griffin2014-07-021-0/+6
| | | | | | | | Better encapsulates its internals from `ActiveRecord::Base`.
* | Don't error when `dup`ing a record with no PKSean Griffin2014-07-021-0/+6
|/
* Use `Hash#transform_values` to clean up `AttributeSet`Sean Griffin2014-06-291-7/+3
|
* `Attribute` should know about its nameSean Griffin2014-06-261-8/+6
| | | | | This allows using polymorphism for the uninitialized attributes raising an exception behavior.
* Encapsulate the creation of `Attribute` objectsSean Griffin2014-06-261-1/+9
| | | | | | | | This will make it less painful to add additional properties, which should persist across writes, such as `name`. Conflicts: activerecord/lib/active_record/attribute_set.rb
* Merge pull request #15868 from sgrif/sg-uninitialized-attributesRafael Mendonça França2014-06-261-17/+24
|\ | | | | | | | | | | | | | | Move behavior of `read_attribute` to `AttributeSet` Conflicts: activerecord/lib/active_record/attribute_set.rb activerecord/test/cases/attribute_set_test.rb
| * Move behavior of `read_attribute` to `AttributeSet`Sean Griffin2014-06-251-17/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moved `Builder` to its own file, as it started looking very weird once I added private methods to the `AttributeSet` class and the `Builder` class started to grow. Would like to refactor `fetch_value` to change to ```ruby self[name].value(&block) ``` But that requires the attributes to know about their name, which they currently do not.
* | Merge pull request #15846 from sgrif/sg-attributes-before-type-castRafael Mendonça França2014-06-261-1/+5
|\ \ | |/ |/| | | | | | | | | | | Move `attributes_before_type_cast` to `AttributeSet` Conflicts: activerecord/lib/active_record/attribute_set.rb activerecord/test/cases/attribute_set_test.rb
| * Move `attributes_before_type_cast` to `AttributeSet`Sean Griffin2014-06-211-1/+5
| |
* | add missing `:nodoc:` for recent refactorings. [ci skip]Yves Senn2014-06-241-2/+1
| | | | | | | | | | | | | | | | | | | | Adding `# :nodoc:` to the parent `class` / `module` is not going to ignore nested classes or modules. There is a modifier `# :nodoc: all` but sadly the containing class or module will continue to be in the docs. /cc @sgrif
* | `reload` should fully reload attributesSean Griffin2014-06-221-4/+0
| | | | | | | | | | | | `reload` is meant to put a record in the same state it would be if you were to do `Post.find(post.id)`. This means we should fully replace the attributes hash.
* | Merge pull request #15839 from sgrif/sg-attr-set-nullYves Senn2014-06-221-1/+2
|\ \ | | | | | | Return a null object from `AttributeSet#[]`
| * | Return a null object from `AttributeSet#[]`Sean Griffin2014-06-201-1/+2
| |/
* / Move `attributes` to the `AttributeSet` object.Sean Griffin2014-06-211-0/+5
|/
* Introduce an object to aid in creation and management of `@attributes`Sean Griffin2014-06-191-0/+51
Mostly delegation to start, but we can start moving a lot of behavior in bulk to this object.