1. 14 6月, 2014 1 次提交
    • S
      Introduce an Attribute object to handle the type casting dance · 6f08db05
      Sean Griffin 提交于
      There's a lot more that can be moved to these, but this felt like a good
      place to introduce the object. Plans are:
      
      - Remove all knowledge of type casting from the columns, beyond a
        reference to the cast_type
      - Move type_cast_for_database to these objects
      - Potentially make them mutable, introduce a state machine, and have
        dirty checking handled here as well
      - Move `attribute`, `decorate_attribute`, and anything else that
        modifies types to mess with this object, not the columns hash
      - Introduce a collection object to manage these, reduce allocations, and
        not require serializing the types
      6f08db05
  2. 05 6月, 2014 1 次提交
  3. 04 6月, 2014 1 次提交
  4. 03 6月, 2014 1 次提交
  5. 02 6月, 2014 2 次提交
    • S
      Remove most code related to serialized properties · 90c8be76
      Sean Griffin 提交于
      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
      90c8be76
    • S
      Don't change values in `@raw_attributes` during serialization · 93734629
      Sean Griffin 提交于
      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.
      93734629
  6. 31 5月, 2014 1 次提交
    • S
      Rename attribute related instance variables to better express intent · eb6cee9c
      Sean Griffin 提交于
      `@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.
      eb6cee9c
  7. 24 5月, 2014 1 次提交
    • S
      Remove `Column#primary` · 05dd3df3
      Sean Griffin 提交于
      It appears to have been used at some point in the past, but is no longer
      used in any meaningful way. Whether a column is considered primary is
      a property of the model, not the schema/column. This also removes the
      need for yet another layer of caching of the model's schema, and we can
      leave that to the schema cache.
      05dd3df3
  8. 23 5月, 2014 3 次提交
  9. 15 5月, 2014 1 次提交
  10. 12 5月, 2014 2 次提交
  11. 04 4月, 2014 1 次提交
  12. 11 3月, 2014 1 次提交
    • A
      Fixes STI when 2+ levels deep. · e5f15a83
      Arthur Neves 提交于
      PR #14052 Added a regression where it was only looking for methods in one
      level up, So when the method was defined in a 2+ levels up the
      inheritance chain, the method was not found as defined.
      e5f15a83
  13. 24 2月, 2014 1 次提交
    • G
      Fixed STI classes not defining an attribute method if there is a · 41554319
      Godfrey Chan 提交于
      conflicting private method defined on its ancestors.
      
      The problem is that `method_defined_within?(name, klass, superklass)`
      only works correclty when `klass` and `superklass` are both `Class`es.
      
      If both `klass` and `superklass` are both `Class`es, they share the
      same inheritance chain, so if a method is defined on `klass` but not
      `superklass`, this method must be introduced at some point between
      `klass` and `superklass`.
      
      This does not work when `superklass` is a `Module`. A `Module`'s
      inheritance chain contains just itself. So if a method is defined on
      `klass` but not on `superklass`, the method could still be defined
      somewhere upstream, e.g. in `Object`.
      
      This fix works by avoiding calling `method_defined_within?` with a
      module while still fufilling the requirement (checking that the
      method is defined withing `superclass` but not is not a generated
      attribute method).
      
      4d8ee288 is likely an attempted partial fix for this problem. This
      unrolls that fix and properly check the `superclass` as intended.
      
      Fixes #11569.
      41554319
  14. 30 1月, 2014 2 次提交
  15. 19 12月, 2013 1 次提交
  16. 30 10月, 2013 1 次提交
  17. 25 10月, 2013 1 次提交
  18. 30 9月, 2013 1 次提交
    • T
      Fix AR#method_missing re-dispatching into overwritten attribute methods. · e9bf87f0
      thedarkone 提交于
      This was happening when a `super` call in an overwritten attribute method
      was triggering a method_missing fallback, because attribute methods
      haven't been generated yet.
      
        class Topic < ActiveRecord::Base
          def title
            # `super` would re-invoke this method if define_attribute_methods
            # hasn't been called yet resulting in double '!' appending
            super + '!'
          end
        end
      e9bf87f0
  19. 29 9月, 2013 1 次提交
  20. 16 7月, 2013 1 次提交
  21. 10 7月, 2013 1 次提交
  22. 09 7月, 2013 1 次提交
  23. 04 7月, 2013 3 次提交
  24. 03 7月, 2013 10 次提交