Module: Nexpose::Attributes

Defined in:
lib/nexpose/util.rb

Overview

Functions for handling attributes as understood by the API. In particular, the API expects a JSON object with the hash defined as:

{ "key": "key-string",
  "value": "value-string" }

Class Method Summary collapse

Class Method Details

.to_hash(arr) ⇒ Array[Hash]

Convert an array of attributes into a hash consumable by the API.

Parameters:

  • arr (Array[Hash])

    Array of attributes to convert.

Returns:

  • (Array[Hash])

    Array formatted as expected by the API.



123
124
125
# File 'lib/nexpose/util.rb', line 123

def to_hash(arr)
  arr.map(&:flatten).map { |p| { 'key' => p.first.to_s, 'value' => p.last.to_s } }
end