Class: Ros::Sdk::Client
- Inherits:
-
Object
- Object
- Ros::Sdk::Client
- Defined in:
- lib/ros_sdk/sdk.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.domain ⇒ Object
Returns the value of attribute domain.
-
.force_path_style ⇒ Object
Returns the value of attribute force_path_style.
-
.host ⇒ Object
Returns the value of attribute host.
-
.port ⇒ Object
Returns the value of attribute port.
-
.scheme ⇒ Object
Returns the value of attribute scheme.
-
.service ⇒ Object
Returns the value of attribute service.
Class Method Summary collapse
- .configure(scheme: 'https', host: nil, domain: nil, port: nil, force_path_style: false, service: nil, connection_type: 'host') ⇒ Object
- .endpoint ⇒ Object
Class Attribute Details
.domain ⇒ Object
Returns the value of attribute domain.
56 57 58 |
# File 'lib/ros_sdk/sdk.rb', line 56 def domain @domain end |
.force_path_style ⇒ Object
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 |
.host ⇒ Object
Returns the value of attribute host.
56 57 58 |
# File 'lib/ros_sdk/sdk.rb', line 56 def host @host end |
.port ⇒ Object
Returns the value of attribute port.
56 57 58 |
# File 'lib/ros_sdk/sdk.rb', line 56 def port @port end |
.scheme ⇒ Object
Returns the value of attribute scheme.
56 57 58 |
# File 'lib/ros_sdk/sdk.rb', line 56 def scheme @scheme end |
.service ⇒ Object
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 |
.endpoint ⇒ Object
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 |