Class: Multiwoven::Integrations::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/multiwoven/integrations/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|self.class.config| ... } ⇒ Service

Returns a new instance of Service.

Yields:



6
7
8
# File 'lib/multiwoven/integrations/service.rb', line 6

def initialize
  yield(self.class.config) if block_given?
end

Class Method Details

.configObject



37
38
39
# File 'lib/multiwoven/integrations/service.rb', line 37

def config
  @config ||= Config.new
end

.connector_class(connector_type, connector_name) ⇒ Object



23
24
25
26
27
# File 'lib/multiwoven/integrations/service.rb', line 23

def connector_class(connector_type, connector_name)
  Object.const_get(
    "Multiwoven::Integrations::#{connector_type}::#{connector_name}::Client"
  )
end

.connectorsObject

deep_dup, not dup: the entries are the clients' own memoized metadata, so a shallow copy lets one caller's mutation reach every later caller.



12
13
14
15
# File 'lib/multiwoven/integrations/service.rb', line 12

def connectors
  built = built_connectors
  { source: built[:source].deep_dup, destination: built[:destination].deep_dup }
end

.exception_reporterObject



33
34
35
# File 'lib/multiwoven/integrations/service.rb', line 33

def exception_reporter
  config.exception_reporter
end

.loggerObject



29
30
31
# File 'lib/multiwoven/integrations/service.rb', line 29

def logger
  config.logger || default_logger
end

.reset_connectors!Object

The build is memoized for the life of the process, so anything that changes what would be built has to clear it.



19
20
21
# File 'lib/multiwoven/integrations/service.rb', line 19

def reset_connectors!
  @built_connectors = nil
end