Class: BaseHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose_ticketing/helpers/base_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_data, options, mode) ⇒ BaseHelper

Returns a new instance of BaseHelper.



13
14
15
16
17
18
19
20
21
# File 'lib/nexpose_ticketing/helpers/base_helper.rb', line 13

def initialize(service_data, options, mode)
  @service_data = service_data
  @options = options
  @log = NexposeTicketing::NxLogger.instance
  @metrics = NexposeTicketing::TicketMetrics.new

  load_dependencies
  @mode_helper = mode
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/nexpose_ticketing/helpers/base_helper.rb', line 11

def options
  @options
end

#service_dataObject

Returns the value of attribute service_data.



11
12
13
# File 'lib/nexpose_ticketing/helpers/base_helper.rb', line 11

def service_data
  @service_data
end

Instance Method Details

#finishObject

Performs any necessary clean-up



40
41
42
# File 'lib/nexpose_ticketing/helpers/base_helper.rb', line 40

def finish
  @metrics.finish
end

#load_dependenciesObject

Load the mode helper specified in the config



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nexpose_ticketing/helpers/base_helper.rb', line 24

def load_dependencies  
  file = "#{@options[:ticket_mode]}_mode.rb".downcase
  path = File.join(File.dirname(__FILE__), "../modes/#{file}")

  @log.log_message("Loading #{@options[:ticket_mode]} mode dependencies.")
  begin 
    require_relative path
  rescue => e
    error = "Ticket mode dependency '#{file}' could not be loaded."
    @log.log_error_message e.to_s
    @log.log_error_message error
    fail error
  end 
end