support_table_cache 1.1.0 → 1.1.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/CHANGELOG.md +10 -0
- data/VERSION +1 -1
- data/lib/support_table_cache/find_by_override.rb +2 -2
- data/lib/support_table_cache/relation_override.rb +4 -2
- data/lib/support_table_cache.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96d5ff63c1cd08f7389bf3b409d0afc4f706f42bed958c7b3a7f2b592d391453
|
4
|
+
data.tar.gz: 76e59a449b9eeffd9df794f014abcbf324f4df2590e250817a4dd3b77467e5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970762a6cb7aaf507552dce376efbcf1da64feb54b261fa315aaff2fc8898b4b8d3db755690c3c09e57e4c615ac7ae23e334e8d1426613b59a800a34c55f6b52
|
7
|
+
data.tar.gz: deed3048a34f40d30aec7c902f09f265642e34a6e8108cca9db806929ab74ef57fd2f31d24b01dd892717a463e5c3bfdb1f6aaaf15b74d9b791d987560c2bc0f
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 1.1.2
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- Do not cache records where only some of the columns have been loaded with a call to `select`.
|
11
|
+
|
12
|
+
## 1.1.1
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Fixed disabled and disable_cache methods to yield a block to match the documentation.
|
16
|
+
|
7
17
|
## 1.1.0
|
8
18
|
|
9
19
|
### Added
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -6,10 +6,10 @@ module SupportTableCache
|
|
6
6
|
# Override for the find_by method that looks in the cache first.
|
7
7
|
def find_by(*args)
|
8
8
|
cache = current_support_table_cache
|
9
|
-
return super
|
9
|
+
return super unless cache
|
10
10
|
|
11
11
|
cache_key = nil
|
12
|
-
attributes = (args.size == 1 && args.first.is_a?(Hash) ? args.first.stringify_keys : {})
|
12
|
+
attributes = ((args.size == 1 && args.first.is_a?(Hash)) ? args.first.stringify_keys : {})
|
13
13
|
|
14
14
|
if respond_to?(:scope_attributes) && scope_attributes.present?
|
15
15
|
attributes = scope_attributes.stringify_keys.merge(attributes)
|
@@ -9,10 +9,12 @@ module SupportTableCache
|
|
9
9
|
return super unless klass.include?(SupportTableCache)
|
10
10
|
|
11
11
|
cache = klass.send(:current_support_table_cache)
|
12
|
-
return super
|
12
|
+
return super unless cache
|
13
|
+
|
14
|
+
return super if select_values.present?
|
13
15
|
|
14
16
|
cache_key = nil
|
15
|
-
attributes = (args.size == 1 && args.first.is_a?(Hash) ? args.first.stringify_keys : {})
|
17
|
+
attributes = ((args.size == 1 && args.first.is_a?(Hash)) ? args.first.stringify_keys : {})
|
16
18
|
|
17
19
|
# Apply any attributes from the current relation chain
|
18
20
|
if scope_attributes.present?
|
data/lib/support_table_cache.rb
CHANGED
@@ -45,6 +45,7 @@ module SupportTableCache
|
|
45
45
|
save_val = Thread.current.thread_variable_get(varname)
|
46
46
|
begin
|
47
47
|
Thread.current.thread_variable_set(varname, !!disabled)
|
48
|
+
yield
|
48
49
|
ensure
|
49
50
|
Thread.current.thread_variable_set(varname, save_val)
|
50
51
|
end
|
@@ -53,8 +54,8 @@ module SupportTableCache
|
|
53
54
|
# Enable the caching behavior for this class within the block. The enabled setting
|
54
55
|
# for a class will always take precedence over the global setting.
|
55
56
|
#
|
56
|
-
# @return
|
57
|
-
def enable_cache
|
57
|
+
# @yieldreturn The return value of the block.
|
58
|
+
def enable_cache(&block)
|
58
59
|
disable_cache(false, &block)
|
59
60
|
end
|
60
61
|
|
@@ -133,7 +134,7 @@ module SupportTableCache
|
|
133
134
|
end
|
134
135
|
|
135
136
|
def current_support_table_cache
|
136
|
-
return nil
|
137
|
+
return nil if support_table_cache_disabled?
|
137
138
|
SupportTableCache.testing_cache || support_table_cache_impl || SupportTableCache.cache
|
138
139
|
end
|
139
140
|
end
|
@@ -149,6 +150,7 @@ module SupportTableCache
|
|
149
150
|
save_val = Thread.current.thread_variable_get(:support_table_cache_disabled)
|
150
151
|
begin
|
151
152
|
Thread.current.thread_variable_set(:support_table_cache_disabled, !!disabled)
|
153
|
+
yield
|
152
154
|
ensure
|
153
155
|
Thread.current.thread_variable_set(:support_table_cache_disabled, save_val)
|
154
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: support_table_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|