hoardable 0.18.2 → 0.19.0
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 +16 -0
- data/lib/hoardable/arel_visitors.rb +1 -1
- data/lib/hoardable/database_client.rb +2 -2
- data/lib/hoardable/engine.rb +19 -12
- data/lib/hoardable/has_many.rb +3 -3
- data/lib/hoardable/scopes.rb +1 -1
- data/lib/hoardable/version.rb +1 -1
- 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: 12ee4c5fbbd0b35bda5c9b7427015a1d60ca9cc919ac992caca386d4c3664163
|
4
|
+
data.tar.gz: 0020d7f28b85fb70efc3a1b80695f1e9c69f60c954b6aeccb71cedadccb97e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fe01feb0e5260d8072f4a45640517a5041a83c566db15b45cc32d141fa8883cf84a1bec16b8ec043a6b914b28e0e824d1e2820454756501941831613efe95a7
|
7
|
+
data.tar.gz: ceef85ede42a50189fb41de31fe0d4ab6882c2139d825569cd674fdf9611f89fd96721156cad5dee347359f67ecba68d8e9a794c2c6513710a39c2e599975668
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.19.0
|
2
|
+
|
3
|
+
- Ensure that stateful Hoardable class methods `with`, `travel_to` and `at` are thread-safe.
|
4
|
+
|
5
|
+
## 0.18.2
|
6
|
+
|
7
|
+
- Fix for using `update_all` with Hoardable records.
|
8
|
+
|
9
|
+
## 0.18.1
|
10
|
+
|
11
|
+
- Support for STI models.
|
12
|
+
|
13
|
+
## 0.18.0
|
14
|
+
|
15
|
+
- Improved compatibilty with using `ActiveRecord` relationship caching when not using `Hoardable.at`.
|
16
|
+
|
1
17
|
## 0.17.0
|
2
18
|
|
3
19
|
- Much improved performance of setting `hoardable_id` for versions.
|
@@ -46,7 +46,7 @@ module Hoardable
|
|
46
46
|
hoardable_maybe_add_only(left, collector)
|
47
47
|
else
|
48
48
|
return unless left.instance_variable_get("@klass").in?(Hoardable::REGISTRY)
|
49
|
-
return if
|
49
|
+
return if Thread.current[:hoardable_at]
|
50
50
|
|
51
51
|
collector << "ONLY "
|
52
52
|
end
|
@@ -56,7 +56,7 @@ module Hoardable
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def has_one_at_timestamp
|
59
|
-
|
59
|
+
Thread.current[:hoardable_at] || source_record.updated_at
|
60
60
|
rescue NameError
|
61
61
|
raise(UpdatedAtColumnMissingError, source_record.class.table_name)
|
62
62
|
end
|
@@ -93,7 +93,7 @@ module Hoardable
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def initialize_temporal_range
|
96
|
-
upper_bound =
|
96
|
+
upper_bound = Thread.current[:hoardable_travel_to] || Time.now.utc
|
97
97
|
lower_bound = (previous_temporal_tsrange_end || hoardable_source_epoch)
|
98
98
|
|
99
99
|
if upper_bound < lower_bound
|
data/lib/hoardable/engine.rb
CHANGED
@@ -44,13 +44,19 @@ module Hoardable
|
|
44
44
|
|
45
45
|
class << self
|
46
46
|
CONFIG_KEYS.each do |key|
|
47
|
-
define_method(key)
|
47
|
+
define_method(key) do
|
48
|
+
local_config = Thread.current[:hoardable_config] || @config
|
49
|
+
local_config[key]
|
50
|
+
end
|
48
51
|
|
49
52
|
define_method("#{key}=") { |value| @config[key] = value }
|
50
53
|
end
|
51
54
|
|
52
55
|
DATA_KEYS.each do |key|
|
53
|
-
define_method(key)
|
56
|
+
define_method(key) do
|
57
|
+
local_context = Thread.current[:hoardable_context] || @context
|
58
|
+
local_context[key]
|
59
|
+
end
|
54
60
|
|
55
61
|
define_method("#{key}=") { |value| @context[key] = value }
|
56
62
|
end
|
@@ -60,14 +66,13 @@ module Hoardable
|
|
60
66
|
#
|
61
67
|
# @param hash [Hash] config and contextual data to set within a block
|
62
68
|
def with(hash)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@context = current_context.merge(hash.slice(*DATA_KEYS))
|
69
|
+
thread = Thread.current
|
70
|
+
thread[:hoardable_config] = @config.merge(hash.slice(*CONFIG_KEYS))
|
71
|
+
thread[:hoardable_context] = @context.merge(hash.slice(*DATA_KEYS))
|
67
72
|
yield
|
68
73
|
ensure
|
69
|
-
|
70
|
-
|
74
|
+
thread[:hoardable_config] = nil
|
75
|
+
thread[:hoardable_context] = nil
|
71
76
|
end
|
72
77
|
|
73
78
|
# Allows performing a query for record states at a certain time. Returned {SourceModel}
|
@@ -75,20 +80,22 @@ module Hoardable
|
|
75
80
|
#
|
76
81
|
# @param datetime [DateTime, Time] the datetime or time to temporally query records at
|
77
82
|
def at(datetime)
|
78
|
-
|
83
|
+
thread = Thread.current
|
84
|
+
thread[:hoardable_at] = datetime
|
79
85
|
yield
|
80
86
|
ensure
|
81
|
-
|
87
|
+
thread[:hoardable_at] = nil
|
82
88
|
end
|
83
89
|
|
84
90
|
# Allows calling code to set the upper bound for the temporal range for recorded audits.
|
85
91
|
#
|
86
92
|
# @param datetime [DateTime] the datetime to temporally record versions at
|
87
93
|
def travel_to(datetime)
|
88
|
-
|
94
|
+
thread = Thread.current
|
95
|
+
thread[:hoardable_travel_to] = datetime
|
89
96
|
yield
|
90
97
|
ensure
|
91
|
-
|
98
|
+
thread[:hoardable_travel_to] = nil
|
92
99
|
end
|
93
100
|
|
94
101
|
# @!visibility private
|
data/lib/hoardable/has_many.rb
CHANGED
@@ -13,8 +13,8 @@ module Hoardable
|
|
13
13
|
end
|
14
14
|
|
15
15
|
private def hoardable_scope
|
16
|
-
if
|
17
|
-
|
16
|
+
if Thread.current[:hoardable_at]
|
17
|
+
(hoardable_id = @association.owner.hoardable_id)
|
18
18
|
@association.scope.rewhere(@association.reflection.foreign_key => hoardable_id)
|
19
19
|
else
|
20
20
|
@association.scope
|
@@ -36,7 +36,7 @@ module Hoardable
|
|
36
36
|
# {HasManyExtension} scope is always used when using {Hoardable.at}.
|
37
37
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
38
38
|
def #{args.first}
|
39
|
-
if
|
39
|
+
if Thread.current[:hoardable_at]
|
40
40
|
super.extending
|
41
41
|
else
|
42
42
|
super
|
data/lib/hoardable/scopes.rb
CHANGED
data/lib/hoardable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoardable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- justin talbott
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|