fulfil_api 0.3.0 → 0.3.1

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: e0460289a73e01bd52c8b06a997b9fc62396113cd981dc9a09e87ca900f5c9a6
4
- data.tar.gz: abc95e2905c9a95482dbbba457e2e088a3fd9f02043f89846f2bf60a9bad7b62
3
+ metadata.gz: 31bfb876f7d82e4d803cbacf7b3628f5acb66c086188e1c56c50a37dfe6cb6f4
4
+ data.tar.gz: db1418268779073af449b43f71ccc47a8a4ad1db92c3261b7d22d9821f5155e0
5
5
  SHA512:
6
- metadata.gz: 80682546344bb1ead394205e822881b499188a8d924984acf62c564f5b37527926039b7d6b6bc771a6cf18217396ffbdc7e1483bda04f6a4b2d4fe801c358ea9
7
- data.tar.gz: a7b246c3a4a3addebcfa72ba38bb0e1fe5ccb689e92b3f076beb5686b258c18300ed56481f2aaba8cf367bc98a946a0677e8ecc5cb0884e04092e80c23e188ba
6
+ metadata.gz: 5cdefd3a083ef390084db3a04276c49c02243b0cf39b52f9c6146657f712f68251e3087f636d789978536f106d1a59f1b3c18f014ebc2c6330501654cc94a08a
7
+ data.tar.gz: 0522da7f4f12ebf1753df8512a716a7c496c11d9f0740ea599ecbfc742b7ef026ca4324769d6bba5f2d37ee16ee4cb963baa5d318d46ea9020538c390fe98e02
@@ -16,8 +16,6 @@ module FulfilApi
16
16
  # @param options [Hash, nil] An optional list of configuration options.
17
17
  # Each key in the hash should correspond to a configuration attribute.
18
18
  def initialize(options = {})
19
- @mutex = Mutex.new
20
-
21
19
  # Assigns the optional configuration options
22
20
  options.each_pair do |key, value|
23
21
  send(:"#{key}=", value) if respond_to?(:"#{key}=")
@@ -27,25 +25,6 @@ module FulfilApi
27
25
  set_default_options
28
26
  end
29
27
 
30
- # Provides thread-safe access to missing methods, allowing dynamic handling of configuration options.
31
- #
32
- # @param method [Symbol] The method name.
33
- # @param args [Array] The arguments passed to the method.
34
- # @param block [Proc] An optional block passed to the method.
35
- # @return [void]
36
- def method_missing(method, *args, &block)
37
- @mutex.synchronize { super }
38
- end
39
-
40
- # Ensures that the object responds correctly to methods handled by method_missing.
41
- #
42
- # @param method [Symbol] The method name.
43
- # @param include_private [Boolean] Whether to include private methods.
44
- # @return [Boolean] Whether the object responds to the method.
45
- def respond_to_missing?(method, include_private = false)
46
- @mutex.synchronize { super }
47
- end
48
-
49
28
  private
50
29
 
51
30
  # Sets the default options for the gem configuration.
@@ -61,13 +40,12 @@ module FulfilApi
61
40
  end
62
41
 
63
42
  @configuration = Configuration.new
64
- @configuration_mutex = Mutex.new
65
43
 
66
44
  # Provides thread-safe access to the gem's configuration.
67
45
  #
68
46
  # @return [Fulfil::Configuration] The current configuration object.
69
47
  def self.configuration
70
- @configuration_mutex.synchronize { @configuration }
48
+ Thread.current[:fulfil_api_configuration] ||= Configuration.new
71
49
  end
72
50
 
73
51
  # Allows the configuration of the gem in a thread-safe manner.
@@ -75,23 +53,25 @@ module FulfilApi
75
53
  # @yieldparam [Fulfil::Configuration] config The current configuration object.
76
54
  # @return [void]
77
55
  def self.configure
78
- @configuration_mutex.synchronize { yield(@configuration) }
56
+ yield(configuration)
79
57
  end
80
58
 
81
59
  # Overwrites the configuration with the newly provided configuration options.
82
60
  #
83
61
  # @param options [Hash, Fulfil::Configuration] A list of configuration options for the gem.
84
62
  # @return [Fulfil::Configuration] The updated configuration object.
85
- def self.configuration=(options_or_configuration)
86
- @configuration_mutex.synchronize do
87
- if options_or_configuration.is_a?(Hash)
88
- options_or_configuration.each_pair do |key, value|
89
- @configuration.send(:"#{key}=", value) if @configuration.respond_to?(:"#{key}=")
90
- end
91
- elsif options_or_configuration.is_a?(Configuration)
92
- @configuration = options_or_configuration
63
+ def self.configuration=(options_or_configuration) # rubocop:disable Metrics/MethodLength
64
+ Thread.current[:fulfil_api_configuration] =
65
+ case options_or_configuration
66
+ when Hash
67
+ config = Configuration.new
68
+ options_or_configuration.each { |key, value| config.send(:"#{key}=", value) }
69
+ config
70
+ when Configuration
71
+ options_or_configuration
72
+ else
73
+ raise ArgumentError, "Expected Hash or Configuration, got #{options_or_configuration.class} instead"
93
74
  end
94
- end
95
75
  end
96
76
 
97
77
  # Temporarily applies the provided configuration options within a block,
@@ -107,6 +87,6 @@ module FulfilApi
107
87
  yield
108
88
  ensure
109
89
  # Revert to the original configuration
110
- self.configuration = original_configuration
90
+ Thread.current[:fulfil_api_configuration] = original_configuration
111
91
  end
112
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FulfilApi
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fulfil_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-24 00:00:00.000000000 Z
11
+ date: 2025-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport