aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/serialization.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate `serialized_attributes` without replacementSean Griffin2014-06-141-16/+17
| | | | | We've stopped using it internally, in favor of polymorphism. So should you!
* Detect in-place changes on mutable AR attributesSean Griffin2014-06-131-17/+0
| | | | | | We have several mutable types on Active Record now. (Serialized, JSON, HStore). We need to be able to detect if these have been modified in place.
* Don't query the database schema when calling `serialize`Sean Griffin2014-06-071-4/+2
| | | | | | We need to decorate the types lazily. This is extracted to a separate API, as there are other refactorings that will be able to make use of it, and to allow unit testing the finer points more granularly.
* Refactor determination of whether the field has changedSean Griffin2014-06-031-8/+0
| | | | | The types know more about what is going on than the dirty module. Let's ask them!
* Remove most code related to serialized propertiesSean Griffin2014-06-011-51/+0
| | | | | | | | | | | Nearly completely implemented in terms of custom properties. `_before_type_cast` now stores the raw serialized string consistently, which removes the need to keep track of "state". The following is now consistently true: - `model.serialized == model.reload.serialized` - A model can be dumped and loaded infinitely without changing - A model can be saved and reloaded infinitely without changing
* Don't change values in `@raw_attributes` during serializationSean Griffin2014-06-011-1/+1
| | | | | | During `init_with`, the attributes given to the coder will be placed into `@raw_attributes`. As such, we should read from `@raw_attributes` when encoding, rather than `@attributes`, which has been type cast.
* Rename attribute related instance variables to better express intentSean Griffin2014-05-301-2/+2
| | | | | | | | | `@attributes` was actually used for `_before_type_cast` and friends, while `@attributes_cache` is the type cast version (and caching is the wrong word there, but I'm working on removing the conditionals around that). I opted for `@raw_attributes`, because `_before_type_cast` is also semantically misleading. The values in said hash are in the state given by the form builder or database, so raw seemed to be a good word.
* Move `type_cast_for_write` behavior over to the serialized type objectSean Griffin2014-05-291-37/+2
|
* Refactor serialized types to be partially defined as custom propertiesSean Griffin2014-05-291-20/+6
| | | | | | | Many of the methods defined in `AttributeMethods::Serialization` can be refactored onto this type as well, but this is a reasonable small step. Removes the `Type` class, and the need for `decorate_columns` to handle serialized types.
* Add an interface for type objects to control Ruby => SQLSean Griffin2014-05-261-4/+2
| | | | | Adds the ability to save custom types, which type cast to non-primitive ruby objects.
* Merge pull request #14613 from Sirupsen/fix-serialize-update-columnRafael Mendonça França2014-05-211-0/+8
|\ | | | | | | | | | | | | Fix serialized field returning serialized data after update_column Conflicts: activerecord/CHANGELOG.md
| * Fix serialized field returning serialized data after update_columnSimon Eskildsen2014-04-051-0/+8
| |
* | docs, double meaning of `serialize` argument. Closes #14284.Yves Senn2014-04-141-5/+16
|/ | | | | | | | The second argument to serialize has double meaning: * `class_name` of the Type to serialize * `coder` to use then serializing. The new variable name and the docs better describe that behavior.
* AestheticRafael Mendonça França2014-01-291-6/+5
|
* Fixing issue with activerecord serialization not being able to dump a record ↵Mauricio Linhares2014-01-291-0/+11
| | | | after loading it from YAML - fixes #13861
* Move changed_attributes into dirty.rbKeenan Brock2014-01-221-0/+8
| | | Move serialization dirty into serialization.rb
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-11-071-0/+3
|\
| * warning about saving models with dirty attributesDamien Mathieu2013-10-231-0/+3
| | | | | | | | See #8328
* | `ActiveRecord::Store` works together with PG `hstore` columns.Yves Senn2013-10-251-0/+4
|/ | | | | | This is necessary because as of 5ac2341 `hstore` columns are always stored as `Hash` with `String` keys. `ActiveRecord::Store` expected the attribute to be an instance of `HashWithIndifferentAccess`, which led to the bug.
* fix serialization type cast when value is already unserializedJan Berdajs2013-06-051-1/+5
|
* the typecast value should be passed to the serializer. fixes #10830Aaron Patterson2013-06-051-5/+5
|
* Remove instance level serialized_attributes setting was deprecated.kennyj2013-06-021-7/+0
|
* fix :nodoc: mark on AR::AttributeMethods::Serialization [ci skip]Francesco Rodriguez2013-04-121-2/+2
|
* update ActiveRecord::AttributeMethods::Serialization documentation [ci skip]Francesco Rodriguez2013-04-041-0/+7
|
* Serialized attribute can be serialized in an integer columnRafael Mendonça França2012-12-211-0/+8
| | | | Fix #8575
* Keep the code related to serialization in Serialization module.Nikita Afanasenko2012-11-101-1/+9
| | | | We should not need any `serialized_attributes` checks outside `ActiveRecord::AttributeMethods::Serialization` module.
* Fix `attributes_before_type_cast` for serialised attributes.Nikita Afanasenko2012-10-311-0/+10
| | | | Public method `attributes_before_type_cast` used to return internal AR structure (ActiveRecord::AttributeMethods::Serialization::Attribute), patch fixes this. Now behaves like `read_attribute_before_type_cast` and returns unserialised values.
* Make caller attribute in deprecation methods optionalAlexey Gaziev2012-10-301-1/+1
|
* Provide a call stack for deprecation warnings where needed.Nikita Afanasenko2012-10-291-1/+2
| | | | It's sometimes hard to quickly find where deprecated call was performed, especially in case of migrating between Rails versions. So this is an attempt to improve the call stack part of the warning message by providing caller explicitly.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-281-8/+11
|\ | | | | | | | | Conflicts: actionpack/lib/action_view/helpers/asset_tag_helper.rb
| * update AR/attribute_methods documentation [ci skip]Francesco Rodriguez2012-09-211-8/+11
| |
* | Removing dead code. attribute_cast_code is not called.kennyj2012-09-281-10/+0
|/
* Use instance_accessor: false instead of instance_writer.kennyj2012-08-211-2/+7
|
* Pull more serialize code into a lazy included moduleJon Leighton2012-08-171-60/+63
|
* Optimize instantiation for models which don't use serializeJon Leighton2012-08-171-13/+20
| | | | Those z's were hard to type.
* Added *instance_writer: false* for stored/serialized attributes.kennyj2012-07-071-1/+1
|
* Simplify AR configuration code.Jon Leighton2012-06-151-1/+1
| | | | | Get rid of ActiveModel::Configuration, make better use of ActiveSupport::Concern + class_attribute, etc.
* Fix #5797. Error calling dup method on AR model with serialized fieldkennyj2012-05-301-3/+4
|
* removing dead codeAaron Patterson2012-02-091-8/+0
|
* Merge branch 'master' into instance_readerAaron Patterson2012-02-091-0/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (30 commits) Bump tzinfo. 0.3.31 was released on November 6, 2011. Fix GH #4909. Dependency on TZInfo move from AR to AS. moving ordered hash to normal hash because ruby 1.9.3 hash defaultly ordered one Refactored the OrderedHash related stuff Replaced OrderedHash usage with Ruby 1.9 Hash Replaced OrderedHash with Hash for ruby 1.9 series removed unnecessary code replacing the orderhash with hash for ruby-1.9 Clean up some wording. Fix typo. test title changed corresponding to the test replaced active support ordered hash to ruby hash on active resource PostgreSQL does not work in the same way of the other adapters AR::Relation#pluck: improve to work with joins Fix match docs Fix attribute_before_type_cast for serialized attributes. Fixes #4837. Fix failing request test Fixes in AMo README Update README to mention lint. Trim down Active Model API by removing valid? and errors.full_messages ...
| * Fix attribute_before_type_cast for serialized attributes. Fixes #4837.Jon Leighton2012-02-071-0/+8
| |
* | give each PG type a `type` method and decortate tz attributesAaron Patterson2012-02-071-0/+4
| |
* | wrap and cache columns for typecastingAaron Patterson2012-02-071-0/+10
| |
* | moved most of the evald code in to regular ruby codeAaron Patterson2012-02-071-2/+2
| |
* | copy the columns hash to the active record instances, typecast using columns ↵Aaron Patterson2012-02-071-0/+8
|/ | | | looked up on the instance
* Support configuration on ActiveRecord::Model.Jon Leighton2011-12-281-1/+1
| | | | | | | | | | | | | | | The problem: We need to be able to specify configuration in a way that can be inherited to models that include ActiveRecord::Model. So it is no longer sufficient to put 'top level' config on ActiveRecord::Base, but we do want configuration specified on ActiveRecord::Base and descendants to continue to work. So we need something like class_attribute that can be defined on a module but that is inherited when ActiveRecord::Model is included. The solution: added ActiveModel::Configuration module which provides a config_attribute macro. It's a bit specific hence I am not putting this in Active Support or making it a 'public API' at present.
* Make read_attribute code path accessible at the class levelJon Leighton2011-12-221-8/+12
|
* Remove the need for type_cast_attribute.Jon Leighton2011-12-011-8/+0
| | | | This is good because it reduces duplication.
* Don't rely on underscore-prefixed attribute methods.Jon Leighton2011-12-011-7/+4
| | | | | | Define singleton methods on the attributes module instead. This reduces method pollution on the actual model classes. It also seems to make something faster, I am unsure why! O_o
* consistencyJon Leighton2011-11-301-4/+4
|