Class: Ros::Sdk::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ros_sdk/sdk.rb

Direct Known Subclasses

Platform::Client

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.domainObject

Returns the value of attribute domain.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def domain
  @domain
end

.force_path_styleObject

Returns the value of attribute force_path_style.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def force_path_style
  @force_path_style
end

.hostObject

Returns the value of attribute host.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def host
  @host
end

.portObject

Returns the value of attribute port.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def port
  @port
end

.schemeObject

Returns the value of attribute scheme.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def scheme
  @scheme
end

.serviceObject

Returns the value of attribute service.



56
57
58
# File 'lib/ros_sdk/sdk.rb', line 56

def service
  @service
end

Class Method Details

.configure(scheme: 'https', host: nil, domain: nil, port: nil, force_path_style: false, service: nil, connection_type: 'host') ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ros_sdk/sdk.rb', line 58

def configure(scheme: 'https', host: nil, domain: nil, port: nil, force_path_style: false, service: nil, connection_type: 'host')
  if descendants.any?
    descendants.map(&:to_s).sort.each do |client|
      client.constantize.configure(scheme: scheme, host: host, domain: domain, port: port, force_path_style: force_path_style, service: service)
      port += 1 if connection_type.eql? 'port'
    end
    return
  end
  self.scheme = scheme
  self.host = host
  self.domain = domain
  self.port = port
  self.force_path_style = force_path_style
  self.service = (service || parent.name.split('::').last).downcase
  Ros::Sdk.configured_services ||= {}
  Ros::Sdk.configured_services[self.service] = parent
  parent::Base.site = endpoint
  parent::Base.connection.use Ros::Sdk::Middleware
  Ros::Sdk.configured_services[self.service]
end

.endpointObject



79
80
81
82
83
84
85
86
# File 'lib/ros_sdk/sdk.rb', line 79

def endpoint
  path = force_path_style ? "/#{service}" : nil
  chost = force_path_style ? host : (host || service)
  chost = [chost, domain].compact.join('.')
  "URI::#{scheme.upcase}".constantize.build({ host: chost, port: port, path: path }).to_s
rescue
  raise 'ClientConfigurationError'
end