Module: FulfilApi
- Defined in:
- lib/fulfil_api.rb,
lib/fulfil_api/error.rb,
lib/fulfil_api/client.rb,
lib/fulfil_api/version.rb,
lib/fulfil_api/resource.rb,
lib/fulfil_api/test_helper.rb,
lib/fulfil_api/access_token.rb,
lib/fulfil_api/configuration.rb,
lib/fulfil_api/resource/relation.rb,
lib/fulfil_api/resource/attribute_type.rb,
lib/fulfil_api/resource/relation/naming.rb,
lib/fulfil_api/resource/relation/loadable.rb,
lib/fulfil_api/resource/attribute_assignable.rb,
lib/fulfil_api/resource/relation/query_methods.rb
Defined Under Namespace
Modules: TestHelper Classes: AccessToken, Client, Configuration, Error, Resource
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
-
.client ⇒ FulfilApi::Client
Builds an HTTP client to interact with an API endpoint of Fulfil.
-
.configuration ⇒ Fulfil::Configuration
Provides thread-safe access to the gem’s configuration.
-
.configuration=(options_or_configuration) ⇒ Fulfil::Configuration
Overwrites the configuration with the newly provided configuration options.
-
.configure {|config| ... } ⇒ void
Allows the configuration of the gem in a thread-safe manner.
-
.with_config(temporary_options) { ... } ⇒ void
Temporarily applies the provided configuration options within a block, and then reverts to the original configuration after the block executes.
Class Method Details
.client ⇒ FulfilApi::Client
Builds an HTTP client to interact with an API endpoint of Fulfil.
To use a different configuration, wrap the call to the client method into
an {.with_config} block.
FulfilApi.with_config(...) do
FulfilApi.client.get(...)
end
124 125 126 |
# File 'lib/fulfil_api/client.rb', line 124 def self.client Client.new(FulfilApi.configuration) end |
.configuration ⇒ Fulfil::Configuration
Provides thread-safe access to the gem’s configuration.
65 66 67 |
# File 'lib/fulfil_api/configuration.rb', line 65 def self.configuration @configuration_mutex.synchronize { @configuration } end |
.configuration=(options_or_configuration) ⇒ Fulfil::Configuration
Overwrites the configuration with the newly provided configuration options.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fulfil_api/configuration.rb', line 81 def self.configuration=() @configuration_mutex.synchronize do if .is_a?(Hash) .each_pair do |key, value| @configuration.send(:"#{key}=", value) if @configuration.respond_to?(:"#{key}=") end elsif .is_a?(Configuration) @configuration = end end end |
.configure {|config| ... } ⇒ void
This method returns an undefined value.
Allows the configuration of the gem in a thread-safe manner.
73 74 75 |
# File 'lib/fulfil_api/configuration.rb', line 73 def self.configure @configuration_mutex.synchronize { yield(@configuration) } end |
.with_config(temporary_options) { ... } ⇒ void
This method returns an undefined value.
Temporarily applies the provided configuration options within a block,
and then reverts to the original configuration after the block executes.
99 100 101 102 103 104 105 106 107 |
# File 'lib/fulfil_api/configuration.rb', line 99 def self.with_config() original_configuration = configuration.dup self.configuration = yield ensure # Revert to the original configuration self.configuration = original_configuration end |