support_table_data 1.2.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e099c5458f1584fb32b3e3076fc98936270271373d0f9c16085647bd151a51e1
4
- data.tar.gz: b23a06b6ec93349d9de896b6cf43448a2b71347e9344b05afb0bf9de3adee615
3
+ metadata.gz: 8719f2da306b1e4803e773daca19142c381227b2697f5549e3666f962e1e6896
4
+ data.tar.gz: 6cdb23dd575e02d73168ae6498719df66bbf42608498c25994c00011accf1d88
5
5
  SHA512:
6
- metadata.gz: fcdb93b92ed17bda1537f3fa40fed8da49a04db5f752e9b21d48514599daddedcbe682789a8ab4a33e47b9bb2df405df8825041631c9b7ca0d6a48fc6bba7487
7
- data.tar.gz: 22ccf807040781616ddaa70f7e8906162bf1120b9335980da213c82c2414e03d1c6d0a69b2bd13890b53ada1f7d9befc756b869fa4c23e76a3590c2b655d6aa2
6
+ metadata.gz: 283969dba42d61ccdcfcf8614b40492a20e42e05775a0e0a9397ffc275a83a9a5dd3a2abdf639694413a423cd1731c0a0aca811ca58f51fee18c75da7ff99d27
7
+ data.tar.gz: b63681662984a4a0673eeb7d2ec8ada7d4368dcc903acab201331c1270f966ca1dc3de44579a0c5323e59afdecf1c022cdfa728136fa194ea3c7aa8e2329f3f5
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.2.2
8
+
9
+ ### Fixed
10
+
11
+ - Added thread safety to modification of internal class variables.
12
+
7
13
  ## 1.2.1
8
14
 
9
15
  ### Changed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
@@ -10,6 +10,7 @@ module SupportTableData
10
10
 
11
11
  included do
12
12
  # Internal variables used for memoization.
13
+ @mutex = Mutex.new
13
14
  @support_table_data_files = []
14
15
  @support_table_attribute_helpers = {}
15
16
  @support_table_instance_names = {}
@@ -76,7 +77,10 @@ module SupportTableData
76
77
  # @return [void]
77
78
  def add_support_table_data(data_file_path)
78
79
  root_dir = (support_table_data_directory || SupportTableData.data_directory || Dir.pwd)
79
- @support_table_data_files << File.expand_path(data_file_path, root_dir)
80
+ @mutex.synchronize do
81
+ @support_table_data_files += [File.expand_path(data_file_path, root_dir)]
82
+ @support_table_instance_keys = nil
83
+ end
80
84
  define_support_table_named_instances
81
85
  end
82
86
 
@@ -88,8 +92,10 @@ module SupportTableData
88
92
  # @param attributes [String, Symbol] The names of the attributes to add helper methods for.
89
93
  # @return [void]
90
94
  def named_instance_attribute_helpers(*attributes)
91
- attributes.flatten.collect(&:to_s).each do |attribute|
92
- @support_table_attribute_helpers[attribute] = []
95
+ @mutex.synchronize do
96
+ attributes.flatten.collect(&:to_s).each do |attribute|
97
+ @support_table_attribute_helpers = @support_table_attribute_helpers.merge(attribute => [])
98
+ end
93
99
  end
94
100
  define_support_table_named_instances
95
101
  end
@@ -207,7 +213,9 @@ module SupportTableData
207
213
  next unless data.is_a?(Hash)
208
214
 
209
215
  data.each do |name, attributes|
210
- define_support_table_named_instance_methods(name, attributes)
216
+ @mutex.synchronize do
217
+ define_support_table_named_instance_methods(name, attributes)
218
+ end
211
219
  end
212
220
  end
213
221
  end
@@ -230,17 +238,15 @@ module SupportTableData
230
238
  unless @support_table_instance_names.include?(method_name)
231
239
  define_support_table_instance_helper(method_name, key_attribute, key_value)
232
240
  define_support_table_predicates_helper("#{method_name}?", key_attribute, key_value)
233
- @support_table_instance_names[method_name] = key_value
241
+ @support_table_instance_names = @support_table_instance_names.merge(method_name => key_value)
234
242
  end
235
243
 
236
- if defined?(@support_table_attribute_helpers)
237
- @support_table_attribute_helpers.each do |attribute_name, defined_methods|
238
- attribute_method_name = "#{method_name}_#{attribute_name}"
239
- next if defined_methods.include?(attribute_method_name)
244
+ @support_table_attribute_helpers.each do |attribute_name, defined_methods|
245
+ attribute_method_name = "#{method_name}_#{attribute_name}"
246
+ next if defined_methods.include?(attribute_method_name)
240
247
 
241
- define_support_table_instance_attribute_helper(attribute_method_name, attributes[attribute_name])
242
- defined_methods << attribute_method_name
243
- end
248
+ define_support_table_instance_attribute_helper(attribute_method_name, attributes[attribute_name])
249
+ defined_methods << attribute_method_name
244
250
  end
245
251
  end
246
252
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: support_table_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.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: 2024-05-24 00:00:00.000000000 Z
11
+ date: 2024-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.4.12
75
+ rubygems_version: 3.4.10
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Extension for ActiveRecord models to manage synchronizing data in support/lookup