Class: MultiInfo::API::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/multiinfo/api/executor.rb

Instance Method Summary collapse

Constructor Details

#initialize(authentication_hash, certificate_hash, debug = false, test_mode = false) ⇒ Executor

Returns a new instance of Executor.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/multiinfo/api/executor.rb', line 15

def initialize(authentication_hash, certificate_hash, debug=false, test_mode=false)
  @authentication_hash = authentication_hash
  @client_cert_file = { 
    :cert => certificate_hash[:client_cert] || File.join(DEFAULT_CONFIG_PATH, DEFAULT_CERT_FILE),
    :rsa_key  => certificate_hash[:client_key] || File.join(DEFAULT_CONFIG_PATH, DEFAULT_KEY_FILE)
  }
  @client_cert_file[:ca_path] = certificate_hash[:ca_path] unless certificate_hash[:ca_path].blank?
  @debug = debug
  @test_mode = test_mode

  allow_request_recording if @test_mode
end

Instance Method Details

#execute(command_name, parameters = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/multiinfo/api/executor.rb', line 28

def execute(command_name, parameters={})
  request_uri = command(command_name, parameters)
  puts "[multiinfo debug] Executing command '#{command_name}': #{request_uri}" if @debug
  ret = [command_name, get_response(request_uri)]
  puts "[multiinfo debug] Raw response: #{ret[1]}" if @debug
  ret
end

#in_test_mode?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/multiinfo/api/executor.rb', line 36

def in_test_mode?
  @test_mode
end