aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/current_attributes.rb
Commit message (Collapse)AuthorAgeFilesLines
* Support before_reset callback in CurrentAttributesRosa Gutierrez2019-01-301-0/+6
| | | | | | | | | This is useful when we need to do some work associated to `Current.reset` but that work depends on the values of the current attributes themselves. This cannot be done in the supported `resets` callback because when the block is executed, CurrentAttributes's instance has already been reset. For symmetry, `after_reset` is defined as alias of `resets`.
* Missing require "active_support/callbacks"Akira Matsuda2018-10-201-0/+2
|
* [ci skip] Prefer cookies.encrypted over signed (#30129)Claudio B2017-08-071-1/+1
| | | | | | | | | | | | | | | | In some examples and guides we are recommending to use code like: ```ruby verified_user = User.find_by(id: cookies.signed[:user_id]) ``` My suggestion is to use instead: ```ruby verified_user = User.find_by(id: cookies.encrypted[:user_id]) ``` which invites users to prefer the "newer" encrypted cookies over the "legacy" signed cookies.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Clear all current instances before a reload.Kasper Timm Hansen2017-05-281-0/+5
| | | | | | | | | | | | | | | If users added an attribute or otherwise changed a CurrentAttributes subclass they'd see exceptions on the next page load. Because `ActiveSupport::CurrentAttributes.current_instances` would keep references to the old instances from the previous request. We can fix this by clearing out the `current_attributes` before we unload constants. Then any change to the model can be autoloaded again since its slot isn't taken by an old instance. We'll still have to call reset before we clear so external collaborators, like Time.zone, won't linger with their current value throughout other code.
* Remove double Thread.current storage.Kasper Timm Hansen2017-05-281-5/+3
| | | | | Since we're generating a key through the class name we can combine the two Thread.current calls into a single hash version.
* Use non-raising finder.Kasper Timm Hansen2017-05-271-1/+1
| | | | | | `find` raises when it can't find a record, so we'll never reach the else. Switch to `find_by` which returns nil when no record can be found.
* [ci skip] Fix spelling that's a bit of an overreach.Kasper Timm Hansen2017-05-271-1/+1
|
* ActiveSupport::CurrentAttributes provides a thread-isolated attributes ↵David Heinemeier Hansson2017-05-261-0/+190
singleton (#29180) * Add ActiveSupport::CurrentAttributes to provide a thread-isolated attributes singleton * Need to require first * Move stubs into test namespace. Thus they won't conflict with other Current and Person stubs. * End of the line for you, whitespace! * Support super in attribute methods. Define instance level accessors in an included module such that `super` in an overriden accessor works, akin to Active Model. * Spare users the manual require. Follow the example of concerns, autoload in the top level Active Support file. * Add bidelegation support * Rename #expose to #set. Simpler, clearer * Automatically reset every instance. Skips the need for users to actively embed something that resets their CurrentAttributes instances. * Fix test name; add tangible name value when blank. * Try to ensure we run after a request as well. * Delegate all missing methods to the instance This allows regular `delegate` to serve, so we don't need bidelegate. * Properly test resetting after execution cycle. Also remove the stale puts debugging. * Update documentation to match new autoreset