class Eso::ConfigurationAttribute

The ConfigurationAttribute is a property of the Configuration

Attributes

property[RW]
value[RW]
value_class[RW]

Public Class Methods

load(array) click to toggle source

Load a ConfigurationAttribute object from an Array

@param [Array] array The Array containing the ConfigurationAttribute object @return [ConfigurationAttribute] The ConfigurationAttribute object which was in the Array

# File lib/eso/configuration/configuration.rb, line 112
def self.load(array)
  property = array.first
  value_class = array.last['valueClass']
  value =
      if value_class == Eso::Values::ARRAY
        array.last['items'].map{|item| item['value']}
      else
        array.last['value']
      end
  self.new(property, value_class, value)
end
new(property, value_class, value) click to toggle source
# File lib/eso/configuration/configuration.rb, line 78
def initialize(property, value_class, value)
  @property = property
  @value_class = value_class
  @value = value
end

Public Instance Methods

to_hash() click to toggle source

Convert the ConfigurationAttribute to a Hash

@return [Hash] A Hash representation of the ConfigurationAttribute

# File lib/eso/configuration/configuration.rb, line 94
def to_hash
  prop = @property.to_sym
  hash = {prop => {}}
  hash[prop]['valueClass'] = @value_class
  if @value_class == Eso::Values::ARRAY
    items = []
    @value.each{|v| items<< {'value' => v, 'valueClass' => Eso::Values::STRING}}
    hash[prop]['items'] = items
  else
    hash[prop]['value'] = @value
  end
  hash
end
to_json() click to toggle source

Convert the ConfigurationAttribute to a JSON string for sending to Nexpose

@return [String] A JSON String representation of the ConfigurationAttribute

# File lib/eso/configuration/configuration.rb, line 87
def to_json
  self.to_hash.to_json
end