Module: FlexmlsApi::MultiClient

Includes:
Configuration
Included in:
FlexmlsApi
Defined in:
lib/flexmls_api/multi_client.rb

Overview

Active support for multiple clients

Constant Summary

Constants included from Configuration

Configuration::DEFAULT_API_KEY, Configuration::DEFAULT_API_SECRET, Configuration::DEFAULT_API_USER, Configuration::DEFAULT_ENDPOINT, Configuration::DEFAULT_OAUTH2, Configuration::DEFAULT_SSL, Configuration::DEFAULT_USER_AGENT, Configuration::DEFAULT_VERSION, Configuration::OAUTH2_KEYS, Configuration::VALID_OPTION_KEYS, Configuration::X_FLEXMLS_API_USER_AGENT

Instance Method Summary collapse

Methods included from Configuration

#configure, extended, #options, #reset_configuration

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 FlexmlsApi.symbol_name method on the FlexmlsApi 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/flexmls_api/multi_client.rb', line 14

def activate(sym)
  if block_given?
    original_client = Thread.current[:flexmls_api_client]
    begin
      activate_client(sym)
      yield
    ensure
      Thread.current[:flexmls_api_client] = original_client
    end
  else
    activate_client(sym)
  end
end