request_store_rails 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/request_locals.rb +4 -1
- data/lib/request_store_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b370ace6ec755d1dc7fa029ee24f92eb5b9caac
|
4
|
+
data.tar.gz: 59be0018678daaa9cf65c25305c8170fc41a9055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff35f1f352936ce0858d15ec30b4e996a7e70e7d62a31137c0303000d1c374a1efa3e02ac6b03f4a7b9822297a693fc96c799ec002167ad32648a3383519349a
|
7
|
+
data.tar.gz: 188fda858dd967a796197b6989e16ef88878eafe72d69dd61282b02cca96487168ea3fc7dc4824f89453261f3e7518ad46f9870c5b92f1d901b6100d1a4bd338
|
data/README.md
CHANGED
@@ -121,6 +121,18 @@ while `RequestLocal[:foo] ||= 'default'` is not. In most scenarios, there is not
|
|
121
121
|
a lot of difference, but if you are in a concurrent environment make sure to
|
122
122
|
use the one that is more suitable for your use case :wink:
|
123
123
|
|
124
|
+
## Replacing `request_store`
|
125
|
+
While the plan is not to achieve 100% compatibility, this gem usually works well
|
126
|
+
as a drop-in replacement. If you are using gems that rely on `RequestStore` but
|
127
|
+
for some reason you need them to use the appropriate request/thread scope, you
|
128
|
+
can try something like this on `application.rb` or similar:3
|
129
|
+
```ruby
|
130
|
+
if RequestStore != RequestLocals
|
131
|
+
RequestStore::Railtie.initializers.clear
|
132
|
+
Kernel.suppress_warnings { RequestStore = RequestLocals }
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
124
136
|
## Special Thanks
|
125
137
|
The inspiration for this gem, tests, and a big part of the readme were borrowed
|
126
138
|
from the really cool [`request_store`](https://github.com/steveklabnik/request_store) gem.
|
data/lib/request_locals.rb
CHANGED
@@ -18,7 +18,7 @@ class RequestLocals
|
|
18
18
|
extend Forwardable
|
19
19
|
|
20
20
|
# Public: Public methods of RequestLocals, they are delegated to the Singleton instance.
|
21
|
-
def_delegators :instance, :clear!, :clear_all!, :[], :[]=, :fetch, :delete, :exist?, :empty?
|
21
|
+
def_delegators :instance, :clear!, :clear_all!, :[], :[]=, :fetch, :delete, :exist?, :key?, :empty?
|
22
22
|
|
23
23
|
# Public: There is no accounting for taste, RequestLocals[:foo] vs RequestLocals.store[:foo]
|
24
24
|
alias_method :store, :instance
|
@@ -63,6 +63,9 @@ class RequestLocals
|
|
63
63
|
store.key?(key)
|
64
64
|
end
|
65
65
|
|
66
|
+
# Public: Alias to exist?
|
67
|
+
alias_method :key?, :exist?
|
68
|
+
|
66
69
|
# Public: Implements fetch in a consistent way with Rails.cache, persisting
|
67
70
|
# the value yielded by the block if the key was not found.
|
68
71
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request_store_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.6.11
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Per-request global storage for Rails
|