Class: GoogleMapsPlatform::BaseController

Inherits:
Object
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/google_maps_platform/controllers/base_controller.rb

Overview

BaseController.

Constant Summary collapse

GLOBAL_ERRORS =
{
  'default' => ErrorCase.new
                        .error_message('HTTP response not OK.')
                        .exception_type(APIException)
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(global_configuration) ⇒ BaseController

Initialization constructor.



32
33
34
35
36
37
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 32

def initialize(global_configuration)
  @global_configuration = global_configuration
  @config = @global_configuration.client_configuration
  @http_call_back = @config.http_callback
  @api_call = ApiCall.new(@global_configuration)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



10
11
12
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 10

def config
  @config
end

#http_call_backObject

Returns the value of attribute http_call_back.



10
11
12
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 10

def http_call_back
  @http_call_back
end

Class Method Details

.user_agentObject



12
13
14
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 12

def self.user_agent
  'Ruby-SDK/1.0.0 [OS: {os-info}, Engine: {engine}/{engine-version}]'
end

.user_agent_parametersObject



16
17
18
19
20
21
22
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 16

def self.user_agent_parameters
  {
    '{engine}' => { 'value' => RUBY_ENGINE, 'encode' => false },
    '{engine-version}' => { 'value' => RUBY_ENGINE_VERSION, 'encode' => false },
    '{os-info}' => { 'value' => RUBY_PLATFORM, 'encode' => false }
  }
end

Instance Method Details

#new_parameter(value, key: nil) ⇒ Parameter

Creates a new instance of the parameter.



61
62
63
64
65
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 61

def new_parameter(value, key: nil)
  Parameter.new
           .key(key)
           .value(value)
end

#new_request_builder(http_method, path, server) ⇒ RequestBuilder

Creates a new instance of the request builder.



44
45
46
47
48
49
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 44

def new_request_builder(http_method, path, server)
  RequestBuilder.new
                .http_method(http_method)
                .path(path)
                .server(server)
end

#new_response_handlerResponseHandler

Creates a new instance of the response handler.



53
54
55
# File 'lib/google_maps_platform/controllers/base_controller.rb', line 53

def new_response_handler
  ResponseHandler.new
end