aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/current_attributes.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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