Class: Ribbon::Intercom::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ribbon/intercom/client.rb,
lib/ribbon/intercom/client/sdk.rb,
lib/ribbon/intercom/client/mock_sdk.rb

Defined Under Namespace

Classes: MockSDK, SDK

Instance Method Summary collapse

Instance Method Details

#[](handle) ⇒ Object



16
17
18
# File 'lib/ribbon/intercom/client.rb', line 16

def [](handle)
  _load_sdk(handle)
end

#config(&block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/ribbon/intercom/client.rb', line 8

def config(&block)
  (@__config ||= Ribbon::Config.new).tap { |config|
    if block_given?
      config.define(&block)
    end
  }
end

#mock_safeObject

Return a mock safe version of this client.



22
23
24
25
26
27
28
29
30
31
# File 'lib/ribbon/intercom/client.rb', line 22

def mock_safe
  dup.tap { |client|
    client.preload_sdks

    # Make SDK instances mock safe
    client.sdk_instances = Hash[
      client.sdk_instances.map { |service, sdk| [service, sdk.mock_safe] }
    ]
  }
end

#preload_sdksObject



33
34
35
36
37
38
39
# File 'lib/ribbon/intercom/client.rb', line 33

def preload_sdks
  if config.service?
    config.service.each { |name, *args|
      _load_sdk(name)
    }
  end
end