1. 12 3月, 2017 1 次提交
  2. 10 3月, 2017 1 次提交
  3. 08 3月, 2017 2 次提交
  4. 05 3月, 2017 1 次提交
  5. 16 1月, 2017 1 次提交
  6. 05 1月, 2017 1 次提交
  7. 30 11月, 2016 1 次提交
  8. 13 11月, 2016 2 次提交
  9. 12 11月, 2016 3 次提交
    • X
      significant speedup of AC::Parameters#permit · 26dd9b26
      Xavier Noria 提交于
      The current implementation of AC::Parameters#permit builds permitted hashes and
      then calls permit! on them.
      
      This filtering is recursive, so we call permit! on terminal branches, but then
      ascendants call permit! on themselves when the recursion goes up the stack,
      which recurses all the way down again because permit! is recursive itself.
      Repeat this for every parent node and you get some scary O-something going on
      that I don't even want to compute.
      
      Instead, since the whole point of the permit recursion is to build permitted
      hashes along the way and at that point you know you've just come up with a
      valid filtered version, you can already switch the toggle on the spot.
      
      I have seen 2x speedups in casual benchmarks with small structures. As the
      previous description shows, the difference in performance is going to be a
      function of the nesting.
      
      Note that that the involved methods are private and used only by permit.
      26dd9b26
    • X
      adds a missing dot [ci skip] · df3c1eef
      Xavier Noria 提交于
      df3c1eef
    • X
      adds support for arbitrary hashes in strong parameters · e86524c0
      Xavier Noria 提交于
      e86524c0
  10. 29 10月, 2016 1 次提交
  11. 27 10月, 2016 1 次提交
  12. 18 10月, 2016 1 次提交
  13. 11 10月, 2016 1 次提交
    • P
      ActionController::Parameters#deep_dup (#26567) · f80ddf30
      Pavel Evstigneev 提交于
      * ActionController::Parameters#deep_dup
      
      * Tests for ActionController::Parameters#deep_dup
      
      * Fix test for ActionController::Parameters#deep_dup
      
      * More tests for ActionController::Parameters#deep_dup
      
      [Rafael Mendonça França + Pavel Evstigneev]
      f80ddf30
  14. 10 10月, 2016 2 次提交
  15. 07 9月, 2016 1 次提交
    • Y
      call `.to_h` to avoid using deprecated method · 700c5583
      yuuji.yaginuma 提交于
      `ActionController::Parameters#merge` call `HashWithIndifferentAccess#merge`.
      In addition, it calls `HashWithIndifferentAccess#update` from
      `HashWithIndifferentAccess#merge`,  where it is called the `#to_hash` of argument.
      But `ActionController::Parameters#to_hash` is deprecated, warning message is
      displayed.
      To avoid this, modify to convert object to `Hash`.
      
      Fixes #26415
      700c5583
  16. 01 9月, 2016 1 次提交
  17. 31 8月, 2016 1 次提交
  18. 16 8月, 2016 1 次提交
  19. 10 8月, 2016 1 次提交
  20. 08 8月, 2016 1 次提交
    • X
      code gardening: removes redundant selfs · a9dc4545
      Xavier Noria 提交于
      A few have been left for aesthetic reasons, but have made a pass
      and removed most of them.
      
      Note that if the method `foo` returns an array, `foo << 1`
      is a regular push, nothing to do with assignments, so
      no self required.
      a9dc4545
  21. 07 8月, 2016 1 次提交
  22. 02 8月, 2016 4 次提交
    • K
      Move the YAML hook closer to `init_with`. · b71732c8
      Kasper Timm Hansen 提交于
      Looked odd, so completely detached from the other necessary part of
      the implementation.
      b71732c8
    • K
      Replace implicit formats with a case statement. · 0e0cff0f
      Kasper Timm Hansen 提交于
      The coder that Psych passes in has a `tag` method we can use to detect
      which serialization format we're reviving for. Use it and make it clearer
      alongside the `load_tags` fiddling.
      0e0cff0f
    • K
      Let Psych 2.0.9+ deserialize 2.0.8 serialized parameters. · 6eb97823
      Kasper Timm Hansen 提交于
      If we were to serialize an `ActionController::Parameters` on Psych 2.0.8, we'd get:
      
      ```yaml
      --- !ruby/hash:ActionController::Parameters
      key: :value
      ```
      
      Because 2.0.8 didn't store instance variables, while 2.0.9 did:
      https://github.com/tenderlove/psych/commit/8f84ad0fc711a82a1040def861cb121e8985fd4c
      
      That, coupled with 2.0.8 calling `new` instead of `allocate` meant parameters was
      deserialized just fine:
      https://github.com/tenderlove/psych/commit/af308f8307899cb9e1c0fffea4bce3110a1c3926
      
      However, if users have 2.0.8 serialized parameters, then upgrade to Psych 2.0.9+ and
      Rails 5, it would start to blow up because `initialize` will never be called, and thus
      `@parameters` will never be assigned. Hello, `NoMethodErrors` on `NilClass`! :)
      
      To fix this we register another variant of the previous serialization format and take
      it into account in `init_with`.
      
      I've tested this in our app and previously raising code now deserializes like a champ.
      I'm unsure how to test this in our suite because we use Psych 2.0.8 and don't know how
      to make us use 2.0.9+ for just one test.
      6eb97823
    • K
      Make Parameters support legacy YAML encodings. · 31448f2b
      Kasper Timm Hansen 提交于
      By changing ActionController::Parameter's superclass, Rails 5 also changed
      the YAML serialization format.
      
      Since YAML doesn't know how to handle parameters it would fallback to its
      routine for the superclass, which in Rails 4.2 was Hash while just Object
      in Rails 5. As evident in the tags YAML would spit out:
      
      4.2: !ruby/hash-with-ivars:ActionController::Parameters
      5.0: !ruby/object:ActionController::Parameters
      
      Thus when loading parameters YAML from 4.2 in Rails 5, it would parse a
      hash dump as it would an Object class.
      
      To fix this we have to provide our own `init_with` to be aware of the past
      format as well as the new one. Then we add a `load_tags` mapping, such that
      when the YAML parser sees `!ruby/hash-with-ivars:ActionController::Parameters`,
      it knows to call our `init_with` function and not try to instantiate it as
      a normal hash subclass.
      31448f2b
  23. 09 7月, 2016 1 次提交
    • T
      Trust `Object#dup` in `ActionController::Parameters`, using `#initialize_copy`... · 96070595
      Tim Rogers 提交于
      Trust `Object#dup` in `ActionController::Parameters`, using `#initialize_copy` to manually duplicate the underlying parameters hash
      
      It looks like `ActionController::Parameters#dup` is leftover from when the class inherited from `Hash`. We can just trust `#dup`, which already copies the `@permitted` instance variable (confirmed by tests). We still define a `#initialize_copy` to make `@parameters` a copy that can be mutated without affecting the original instance.
      96070595
  24. 07 7月, 2016 1 次提交
    • T
      Changes to a dupped `ActionController::Parameters` mutate the original · ba3dd5ca
      Tim Rogers 提交于
      When `ActionController::Parameters` is duplicated with `#dup`, it doesn't create a duplicate of the instance variables (e.g. `@parameters`) but rather maintains the reference (see <http://ruby-doc.org/core-2.3.1/Object.html>). Given that the parameters object is often manipulated as if it were a hash (e.g. with `#delete` and similar methods), this leads to unexpected behaviour, like the following:
      
      ```
      params = ActionController::Parameters.new(foo: "bar")
      duplicated_params = params.dup
      duplicated_params.delete(:foo)
      
      params == duplicated_params
      ```
      
      This fixes the bug by defining a private `#initialize_copy` method, used internally by `#dup`, which makes a copy of `@parameters`.
      ba3dd5ca
  25. 23 6月, 2016 2 次提交
  26. 29 5月, 2016 1 次提交
  27. 28 5月, 2016 1 次提交
  28. 01 5月, 2016 1 次提交
  29. 15 4月, 2016 1 次提交
  30. 24 3月, 2016 1 次提交
  31. 13 3月, 2016 1 次提交