class Ribbon::Intercom::Client
Attributes
sdk_instances[RW]
Public Instance Methods
[](handle)
click to toggle source
# File lib/ribbon/intercom/client.rb, line 16 def [](handle) _load_sdk(handle) end
config(&block)
click to toggle source
# 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_safe()
click to toggle source
Return a mock safe version of this client.
# 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_sdks()
click to toggle source
# File lib/ribbon/intercom/client.rb, line 33 def preload_sdks if config.service? config.service.each { |name, *args| _load_sdk(name) } end end
Private Instance Methods
_load_sdk(handle)
click to toggle source
# File lib/ribbon/intercom/client.rb, line 47 def _load_sdk(handle) raise Errors::ServiceNotDefinedError unless config.service? (self.sdk_instances ||= Hash.new { |hash, key| # Get the last service if there are duplicates if (service_def = config.service.select { |r| r.first == key }.last) name, config = service_def hash[key] = SDK.new(config[:url], config[:token], config[:secret]) else raise Errors::ServiceNotDefinedError end })[handle.to_sym] end