Class: Eso::Configuration
- Inherits:
-
Object
- Object
- Eso::Configuration
- Defined in:
- lib/eso/configuration/configuration.rb
Overview
This class represents the Configuration that is sent to the server for new style Discovery Connections.
Instance Attribute Summary collapse
-
#config_id ⇒ Object
Returns the value of attribute config_id.
-
#config_name ⇒ Object
Returns the value of attribute config_name.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
Class Method Summary collapse
-
.load(hash) ⇒ Configuration
Load a Configuration object from a Hash.
Instance Method Summary collapse
-
#delete_property(name) ⇒ Object
Delete a Configuration attribute property value given the name of the property.
-
#initialize(service_name:, config_name:, properties: [], config_id:) ⇒ Configuration
constructor
A new instance of Configuration.
-
#property(name) ⇒ String
Retrieve a Configuration attribute property value given the name of the property.
-
#to_hash ⇒ Hash
Convert the Configuration to a Hash.
-
#to_json ⇒ String
Convert the Configuration to a JSON string for sending to Nexpose.
-
#update_property(name, value) ⇒ String
Update a Configuration attribute property value given the name of the property.
Constructor Details
#initialize(service_name:, config_name:, properties: [], config_id:) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 |
# File 'lib/eso/configuration/configuration.rb', line 7 def initialize(service_name:, config_name:, properties:[], config_id:) @service_name = service_name @config_name = config_name @properties = properties @config_id = config_id end |
Instance Attribute Details
#config_id ⇒ Object
Returns the value of attribute config_id.
5 6 7 |
# File 'lib/eso/configuration/configuration.rb', line 5 def config_id @config_id end |
#config_name ⇒ Object
Returns the value of attribute config_name.
5 6 7 |
# File 'lib/eso/configuration/configuration.rb', line 5 def config_name @config_name end |
#properties ⇒ Object
Returns the value of attribute properties.
5 6 7 |
# File 'lib/eso/configuration/configuration.rb', line 5 def properties @properties end |
#service_name ⇒ Object
Returns the value of attribute service_name.
5 6 7 |
# File 'lib/eso/configuration/configuration.rb', line 5 def service_name @service_name end |
Class Method Details
.load(hash) ⇒ Configuration
Load a Configuration object from a Hash
63 64 65 66 67 68 69 70 71 |
# File 'lib/eso/configuration/configuration.rb', line 63 def self.load(hash) configuration = self.new(service_name: hash[:serviceName], config_name: hash[:configName], config_id: hash[:configID]) hash[:configurationAttributes][:properties].each do |prop| configuration.properties << ConfigurationAttribute.load(prop) end configuration end |
Instance Method Details
#delete_property(name) ⇒ Object
Delete a Configuration attribute property value given the name of the property
55 56 57 |
# File 'lib/eso/configuration/configuration.rb', line 55 def delete_property(name) properties.delete_if{|attr| attr.property == name} end |
#property(name) ⇒ String
Retrieve a Configuration attribute property value given the name of the property
38 39 40 41 |
# File 'lib/eso/configuration/configuration.rb', line 38 def property(name) prop = properties.find{|attr| attr.property == name} prop.value unless prop.nil? end |
#to_hash ⇒ Hash
Convert the Configuration to a Hash
24 25 26 27 28 29 30 31 32 |
# File 'lib/eso/configuration/configuration.rb', line 24 def to_hash hash = {:configId => @config_id, :serviceName => @service_name, :configName => @config_name, :configurationAttributes => {:valueClass => Eso::Values::OBJECT, :objectType => 'service_configuration', :properties => []}} properties.each {|prop| hash[:configurationAttributes][:properties] << prop.to_hash} end |
#to_json ⇒ String
Convert the Configuration to a JSON string for sending to Nexpose
17 18 19 |
# File 'lib/eso/configuration/configuration.rb', line 17 def to_json self.to_hash.to_json end |
#update_property(name, value) ⇒ String
Update a Configuration attribute property value given the name of the property
48 49 50 |
# File 'lib/eso/configuration/configuration.rb', line 48 def update_property(name, value) properties.find{|attr| attr.property == name}.value = value end |