Class: NexposeSCCM::DataSource::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose_sccm/data_source.rb

Overview

Universal Data object to send back to client and makes the data source transparent

  • Args :

    • data - A resultset, either using the pg_helper or nexpose_helper

    • connection_type - A symbol representing whether to use postgres or nexpose

Instance Method Summary collapse

Constructor Details

#initialize(data, connection_type) ⇒ Data

Returns a new instance of Data.



42
43
44
45
# File 'lib/nexpose_sccm/data_source.rb', line 42

def initialize(data, connection_type)
  @data = data
  @connection_type = connection_type
end

Instance Method Details

#eachObject



47
48
49
50
51
52
# File 'lib/nexpose_sccm/data_source.rb', line 47

def each
  @data.each do |p|
    sym_p = p.inject({}){|res,(k,v)| res[k.to_sym] = v; res}
    yield sym_p
  end
end

#lengthObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/nexpose_sccm/data_source.rb', line 54

def length
  case @connection_type
    when :dwh
      @data.cmd_tuples
    when :nsc
      @data.length
    else
      NexposeSCCM.logger.error("An invalid connection type made it's way in here, exiting...")
      exit 1
  end
end