Class: UAT::Discovery::API

Inherits:
Object
  • Object
show all
Defined in:
lib/uat/discovery/api.rb

Overview

An instance of this API should be used to create all objects needed from this gem The configuration with which it is instantiated controls all instances

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ API

Returns a new instance of API.

Parameters:



7
8
9
# File 'lib/uat/discovery/api.rb', line 7

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#new_clientUAT::Discovery::Interfaces::IClient

Returns a client implementation based on configuration

Returns:



12
13
14
# File 'lib/uat/discovery/api.rb', line 12

def new_client
  @configuration.local_mode? ? new_mock_client : new_real_client
end

#new_mock_clientUAT::Discovery::MockClient



27
28
29
30
31
32
# File 'lib/uat/discovery/api.rb', line 27

def new_mock_client
  MockClient.new(
      @configuration.local_service_urls_keyed_by_service_name,
      self
  )
end

#new_real_clientUAT::Discovery::Client



17
18
19
20
21
22
23
24
# File 'lib/uat/discovery/api.rb', line 17

def new_real_client
  Client.new(
      new_diplomat_service,
      @configuration.protocol,
      self,
      new_path_provider
  )
end

#new_uri(uri_string) ⇒ URI::Generic

Parameters:

  • uri_string

    the uri string that should be converted to a URI object

Returns:

  • (URI::Generic)


36
37
38
# File 'lib/uat/discovery/api.rb', line 36

def new_uri(uri_string)
  URI(uri_string)
end