tablesalt 0.29.1 → 0.29.2
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 +1 -1
- data/lib/tablesalt/class_pass.rb +3 -6
- data/lib/tablesalt/thread_accessor.rb +6 -6
- data/lib/tablesalt/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2db7e690c13560932196c2a042e6c3de2cbe629a172b073d758080f61001aab
|
4
|
+
data.tar.gz: bcee69281970cf50ed6ba3c02de6666456469c1af97088ee087f7552f632b395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e622d92d7104a0fd5d14c81e0e39d6ae716f6dcadeab9945613081438d7bfa16372c49c7e890a7a105326191af96a0633db981a864e2f0d9e4584078fa38e51a
|
7
|
+
data.tar.gz: c7a20552c32892aa997b80b4e355fda096ea7f8c7333a2e85f144b51897ac47357c51894eecfa92d67cd7f9dc719e0775bffc749a9ebf27321ffe6805b783dc7
|
data/README.md
CHANGED
@@ -127,7 +127,7 @@ CurrentUser.current_user
|
|
127
127
|
Yep, when you mess with thread variables, you need to think about thread safety. For Rack applications, `ThreadAccessor` ships with a Rack middleware component:
|
128
128
|
```ruby
|
129
129
|
# in config/initializers/rack.rb, or config/initializers/tablesalt.rb, or anywhere else in your boot path:
|
130
|
-
config.middleware.use
|
130
|
+
Rails.application.config.middleware.use Tablesalt::ThreadAccessor::RackMiddleware
|
131
131
|
```
|
132
132
|
|
133
133
|
If your application isn't on Rack, you'll need to add a little more code manually to take care of this:
|
data/lib/tablesalt/class_pass.rb
CHANGED
@@ -24,15 +24,12 @@ module Tablesalt
|
|
24
24
|
|
25
25
|
_class_pass_methods << method
|
26
26
|
|
27
|
-
define_singleton_method method do |*args, **
|
28
|
-
# TODO: remove this if branch when 2.6 support is removed
|
29
|
-
if RUBY_VERSION < "2.7.0" && attrs.empty?
|
30
|
-
new(*args).public_send(to || method, &block)
|
27
|
+
define_singleton_method method do |*args, **kwargs, &block|
|
31
28
|
# TODO: remove this if branch when 2.7 support is removed
|
32
|
-
|
29
|
+
if RUBY_VERSION < "3.0.0" && args.empty? && kwargs.empty?
|
33
30
|
new.public_send(to || method, &block)
|
34
31
|
else
|
35
|
-
new(*args, **
|
32
|
+
new(*args, **kwargs).public_send(to || method, &block)
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -63,9 +63,9 @@ module Tablesalt
|
|
63
63
|
# => "bar"
|
64
64
|
#
|
65
65
|
# @param method [String, Symbol] The name of the reader method
|
66
|
-
# @param thread_key [String, Symbol] The key to read from Thread.current
|
66
|
+
# @param thread_key [String, Symbol] The key to read from Thread.current. Default: <method>
|
67
67
|
# @option :private [Boolean] If true, both defined methods will be private. Default: true
|
68
|
-
def thread_reader(method, thread_key, **options)
|
68
|
+
def thread_reader(method, thread_key = method, **options)
|
69
69
|
define_method(method) { __thread_accessor_store_instance__[thread_key] }
|
70
70
|
define_singleton_method(method) { __thread_accessor_store_instance__[thread_key] }
|
71
71
|
|
@@ -101,9 +101,9 @@ module Tablesalt
|
|
101
101
|
# to clear the thread store themselves.
|
102
102
|
#
|
103
103
|
# @param method [String, Symbol] The name of the writer method
|
104
|
-
# @param thread_key [String, Symbol] The key to write to on Thread.current
|
104
|
+
# @param thread_key [String, Symbol] The key to write to on Thread.current. Default: <method>
|
105
105
|
# @option :private [Boolean] If true, both defined methods will be private. Default: true
|
106
|
-
def thread_writer(method, thread_key, **options)
|
106
|
+
def thread_writer(method, thread_key = method, **options)
|
107
107
|
method_name = "#{method}="
|
108
108
|
|
109
109
|
define_method(method_name) { |value| __thread_accessor_store_instance__[thread_key] = value }
|
@@ -136,9 +136,9 @@ module Tablesalt
|
|
136
136
|
# => "baz"
|
137
137
|
#
|
138
138
|
# @param method [String, Symbol] The name of the writer method
|
139
|
-
# @param thread_key [String, Symbol] The key to write to on Thread.current
|
139
|
+
# @param thread_key [String, Symbol] The key to write to on Thread.current. Default: <method>
|
140
140
|
# @option :private [Boolean] If true, all defined methods will be private. Default: true
|
141
|
-
def thread_accessor(method, thread_key, **options)
|
141
|
+
def thread_accessor(method, thread_key = method, **options)
|
142
142
|
thread_reader(method, thread_key, **options)
|
143
143
|
thread_writer(method, thread_key, **options)
|
144
144
|
end
|
data/lib/tablesalt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tablesalt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.29.
|
4
|
+
version: 0.29.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Minneti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.0.0
|
41
41
|
description: A package of helpers that introduce some conventions and convenience
|
42
42
|
for common behaviors
|
43
43
|
email:
|
@@ -76,7 +76,7 @@ metadata:
|
|
76
76
|
homepage_uri: https://github.com/RubyAfterAll/spicerack/tree/main/tablesalt
|
77
77
|
source_code_uri: https://github.com/RubyAfterAll/spicerack/tree/main/tablesalt
|
78
78
|
changelog_uri: https://github.com/RubyAfterAll/spicerack/blob/main/tablesalt/CHANGELOG.md
|
79
|
-
documentation_uri: https://www.rubydoc.info/gems/tablesalt/0.29.
|
79
|
+
documentation_uri: https://www.rubydoc.info/gems/tablesalt/0.29.2
|
80
80
|
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.3.
|
95
|
+
rubygems_version: 3.3.15
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Miscellaneous helper modules, POROs, and more, that standardize common behavior
|