aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/serialized.rb
Commit message (Collapse)AuthorAgeFilesLines
* `type_cast_for_database` -> `serialize`Sean Griffin2015-02-171-2/+2
|
* `Type#type_cast_from_database` -> `Type#deserialize`Sean Griffin2015-02-171-1/+1
|
* Move non-type objects into the `Type::Helpers` namespaceSean Griffin2015-02-071-1/+1
| | | | | | | The type code is actually quite accessible, and I'm planning to encourage people to look at the files in the `type` folder to learn more about how it works. This will help reduce the noise from code that is less about type casting, and more about random AR nonsense.
* rm `ActiveRecord::Type::Decorator`Sean Griffin2015-02-071-11/+0
| | | | | | | It only existed to make sure the subclasses of `Delegator` were YAML serializable. As of Ruby 2.2, these are YAML dumpable by default, as it includes https://github.com/tenderlove/psych/commit/2a4d9568f7d5d19c00231cf48eb855cc45ec3394
* Don't treat `nil` as changed in serialized typesSean Griffin2014-12-231-1/+1
| | | | | | | We were ignoring the `default_value?` escape clause in the serialized type, which caused the default value to always be treated as changed. Fixes #18169
* Use `DelegateClass` instead of `SimpleDelegator` for type decoratorsSean Griffin2014-11-141-1/+1
| | | | There is a significant performance difference between the two. Closes
* Allow YAML serialization when using TZ aware attributesSean Griffin2014-09-171-3/+3
|
* Correctly detect mutation on serialized columns mapping to binarySean Griffin2014-08-271-0/+5
| | | | Fixes #16701
* Rename method for clarityCarlos Antonio da Silva2014-07-311-3/+3
| | | | Ruby generally does not use the is_* prefix on predicate methods.
* Remove `serialized?` from the type interfaceSean Griffin2014-06-131-4/+0
|
* Detect in-place changes on mutable AR attributesSean Griffin2014-06-131-4/+2
| | | | | | 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.
* Keep the types of virtual columns after yaml serializationSean Griffin2014-06-101-0/+11
| | | | | On MySQL and PostgreSQL, the adapter does not type cast virtual columns for us.
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-2/+2
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* Make `_before_type_cast` actually be before type castSean Griffin2014-06-091-3/+5
| | | | | | | | | | | | | - The following is now true for all types, all the time - `model.attribute_before_type_cast == given_value` - `model.attribute == model.save_and_reload.attribute` - `model.attribute == model.dup.attribute` - `model.attribute == YAML.load(YAML.dump(model)).attribute` - Removes the remaining types implementing `type_cast_for_write` - Simplifies the implementation of time zone aware attributes - Brings tz aware attributes closer to being implemented as an attribute decorator - Adds additional point of control for custom types
* Do not type cast twice on attribute assignmentSean Griffin2014-06-071-4/+0
| | | | | | | | | | | | | The definition of `write_attribute` in dirty checking ultimately leads to the columns calling `type_cast` on the value to perform the comparison. However, this is a potentially expensive computation that we cache when it occurs in `read_attribute`. The only case that we need the non-type-cast form is for numeric, so we pass that through as well (something I'm looking to remove in the future). This also reduces the number of places that manually access various stages in an attribute's type casting lifecycle, which will aid in one of the larger refactorings that I'm working on.
* serialized Type should delegate `type_cast_for_write` to underlying TypeYves Senn2014-06-061-1/+1
| | | | | | | This adds a regression test for #14411, which was fixed by #15503. Closes #14411 Closes #14595
* Refactor determination of whether the field has changedSean Griffin2014-06-031-0/+4
| | | | | 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-24/+11
| | | | | | | | | | | 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
* Move `type_cast_for_write` behavior over to the serialized type objectSean Griffin2014-05-291-3/+32
|
* Refactor serialized types to be partially defined as custom propertiesSean Griffin2014-05-291-0/+28
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.