1. 10 6月, 2014 7 次提交
    • E
      Abstract away use of HABTM macro · 9eb87fbf
      eileencodes 提交于
      By having the `:has_and_belongs_to_many` macro in the `@collection`
      we are punishing `:has_many` associations because it has to allocate
      the array and check the macro.
      
      @collection is returned to `macro == :has_many` and a new reflection
      class `HABTMReflection` is created to handle this case instead.
      9eb87fbf
    • E
      add has_one? method and reuse instead of checking macro · 5a0b184c
      eileencodes 提交于
      Instead of checking for `macro == :has_one` throughout the
      codebase we can create a `has_one?` method to match the `belongs_to?`,
      `polymorphic?` and other methods.
      5a0b184c
    • R
      Timestamp values should be present on callbacks · dddbccb2
      Rafael Mendonça França 提交于
      This reverts commit dd3ea171 and add a
      regression test.
      
      Fixes #15418
      dddbccb2
    • S
      Rename `type_cast` to `type_cast_from_database` · d24e6407
      Sean Griffin 提交于
      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.
      d24e6407
    • S
      Use an actual identity type in AR::Result#identity_type · 27421620
      Sean Griffin 提交于
      We should be able to rely on this object implenting the full type
      interface.
      27421620
    • R
      Do not try to set the foreign_key again on has_many through · 19f1cfbb
      Rafael Mendonça França 提交于
      Integration tests are inside protected_attributes test suite.
      
      Fixes #15496
      Fixes rails/protected_attributes#35
      19f1cfbb
    • S
      Make `_before_type_cast` actually be before type cast · c93dbfef
      Sean Griffin 提交于
      - 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
      c93dbfef
  2. 09 6月, 2014 1 次提交
  3. 08 6月, 2014 3 次提交
    • S
      Do not type cast twice on attribute assignment · 368cca51
      Sean Griffin 提交于
      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.
      368cca51
    • S
      Move conditionals about freezing closer to the definition of `freeze` · 105e0304
      Sean Griffin 提交于
      Reduces the number of places that care about the internals of how we
      store and type cast attributes. We do not need to go through the
      dup/freeze dance, as you couldn't have saved a frozen new record anyway,
      and that is the only time we would end up modifying the frozen hash.
      105e0304
    • S
      Remove dead branch when restoring ID within a transaction · 35164093
      Sean Griffin 提交于
      There is no way to have an instance of an Active Record model where
      `has_attribute?(self.class.primary_key)` returns false. The record is
      always initialized in such a way that `@raw_attributes` will have an id
      key with nil for the value.
      35164093
  4. 07 6月, 2014 12 次提交
  5. 06 6月, 2014 4 次提交
  6. 05 6月, 2014 4 次提交
  7. 04 6月, 2014 7 次提交
  8. 03 6月, 2014 2 次提交