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/relation.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/relation/naming.rb,
lib/fulfil_api/resource/errors.rb,
lib/fulfil_api/customer_shipment.rb,
lib/fulfil_api/relation/loadable.rb,
lib/fulfil_api/relation/batchable.rb,
lib/fulfil_api/relation/countable.rb,
lib/fulfil_api/resource/comparable.rb,
lib/fulfil_api/resource/persistable.rb,
lib/fulfil_api/resource/serializable.rb,
lib/fulfil_api/relation/query_methods.rb,
lib/fulfil_api/resource/attribute_type.rb,
lib/fulfil_api/resource/attribute_assignable.rb
Defined Under Namespace
Modules: TestHelper Classes: AccessToken, Client, Configuration, CustomerShipment, Error, Relation, Resource
Constant Summary collapse
- VERSION =
"0.3.0"
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
127 128 129 |
# File 'lib/fulfil_api/client.rb', line 127 def self.client Client.new(FulfilApi.configuration) end |
.configuration ⇒ Fulfil::Configuration
Provides thread-safe access to the gem’s configuration.
69 70 71 |
# File 'lib/fulfil_api/configuration.rb', line 69 def self.configuration @configuration_mutex.synchronize { @configuration } end |
.configuration=(options_or_configuration) ⇒ Fulfil::Configuration
Overwrites the configuration with the newly provided configuration options.
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fulfil_api/configuration.rb', line 85 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.
77 78 79 |
# File 'lib/fulfil_api/configuration.rb', line 77 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.
103 104 105 106 107 108 109 110 111 |
# File 'lib/fulfil_api/configuration.rb', line 103 def self.with_config() original_configuration = configuration.dup self.configuration = yield ensure # Revert to the original configuration self.configuration = original_configuration end |