Module: SparkApi::MultiClient
Overview
Active support for multiple clients
Constant Summary
Constants included from Configuration
Configuration::DEFAULT_ACCESS_URI, Configuration::DEFAULT_API_KEY, Configuration::DEFAULT_API_SECRET, Configuration::DEFAULT_API_USER, Configuration::DEFAULT_AUTHORIZATION_URI, Configuration::DEFAULT_AUTH_ENDPOINT, Configuration::DEFAULT_COMPRESS, Configuration::DEFAULT_DICTIONARY_VERSION, Configuration::DEFAULT_ENDPOINT, Configuration::DEFAULT_MIDDLEWARE, Configuration::DEFAULT_OAUTH2, Configuration::DEFAULT_REDIRECT_URI, Configuration::DEFAULT_REQUEST_ID_CHAIN, Configuration::DEFAULT_SESSION_PATH, Configuration::DEFAULT_SSL, Configuration::DEFAULT_SSL_VERIFY, Configuration::DEFAULT_TIMEOUT, Configuration::DEFAULT_USER_AGENT, Configuration::DEFAULT_USER_IP_ADDRESS, Configuration::DEFAULT_VERSION, Configuration::OAUTH2_KEYS, Configuration::VALID_OPTION_KEYS, Configuration::X_SPARK_API_USER_AGENT, Configuration::X_USER_IP_ADDRESS
Instance Method Summary collapse
-
#activate(sym) ⇒ Object
Activate a specific instance of the client (with appropriate config settings).
Methods included from Configuration
#configure, extended, #options, #reset_configuration
Methods included from Configuration::OAuth2Configurable
#convert_to_oauth2?, #grant_uri, #oauth2_enabled?, #oauthify!
Instance Method Details
#activate(sym) ⇒ Object
Activate a specific instance of the client (with appropriate config settings). Each client is lazily instanciated by calling the matching SparkApi.symbol_name method on the SparkApi module. It’s the developers responsibility to extend the module and provide this method. Parameters
@sym - the unique symbol identifier for a client configuration.
&block - a block of code to run with the specified client enabled, after which the original
client setting will be reenabled
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spark_api/multi_client.rb', line 14 def activate(sym) if block_given? original_client = Thread.current[:spark_api_client] begin activate_client(sym) yield ensure Thread.current[:spark_api_client] = original_client end else activate_client(sym) end end |