Class: Eso::ConfigurationAttribute
- Inherits:
-
Object
- Object
- Eso::ConfigurationAttribute
- Defined in:
- lib/eso/configuration/configuration.rb
Overview
The ConfigurationAttribute is a property of the Configuration
Instance Attribute Summary collapse
-
#property ⇒ Object
Returns the value of attribute property.
-
#value ⇒ Object
Returns the value of attribute value.
-
#value_class ⇒ Object
Returns the value of attribute value_class.
Class Method Summary collapse
-
.load(array) ⇒ ConfigurationAttribute
Load a ConfigurationAttribute object from an Array.
Instance Method Summary collapse
-
#initialize(property, value_class, value) ⇒ ConfigurationAttribute
constructor
A new instance of ConfigurationAttribute.
-
#to_hash ⇒ Hash
Convert the ConfigurationAttribute to a Hash.
-
#to_json ⇒ String
Convert the ConfigurationAttribute to a JSON string for sending to Nexpose.
Constructor Details
#initialize(property, value_class, value) ⇒ ConfigurationAttribute
Returns a new instance of ConfigurationAttribute.
78 79 80 81 82 |
# File 'lib/eso/configuration/configuration.rb', line 78 def initialize(property, value_class, value) @property = property @value_class = value_class @value = value end |
Instance Attribute Details
#property ⇒ Object
Returns the value of attribute property.
76 77 78 |
# File 'lib/eso/configuration/configuration.rb', line 76 def property @property end |
#value ⇒ Object
Returns the value of attribute value.
76 77 78 |
# File 'lib/eso/configuration/configuration.rb', line 76 def value @value end |
#value_class ⇒ Object
Returns the value of attribute value_class.
76 77 78 |
# File 'lib/eso/configuration/configuration.rb', line 76 def value_class @value_class end |
Class Method Details
.load(array) ⇒ ConfigurationAttribute
Load a ConfigurationAttribute object from an Array
112 113 114 115 116 117 118 119 120 121 122 |
# 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 |
Instance Method Details
#to_hash ⇒ Hash
Convert the ConfigurationAttribute to a Hash
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# 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 ⇒ String
Convert the ConfigurationAttribute to a JSON string for sending to Nexpose
87 88 89 |
# File 'lib/eso/configuration/configuration.rb', line 87 def to_json self.to_hash.to_json end |