Class: VirtualBox::VirtualSystemDescription
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- VirtualBox::VirtualSystemDescription
- Defined in:
- lib/virtualbox/virtual_system_description.rb
Overview
Represents a description of a virtual system in an Appliance. This contains the values that are in the OVF files as well as recommend values from VirtualBox.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ivsd) ⇒ VirtualSystemDescription
constructor
A new instance of VirtualSystemDescription.
- #initialize_attributes(ivsd) ⇒ Object
Methods inherited from AbstractModel
#destroy, #errors, errors_for_relationship, #existing_record!, #inspect, #lazy_attribute?, #lazy_relationship?, #new_record!, #new_record?, #parent_machine, #populate_attributes, #populate_relationship, #populate_relationships, reload!, #reload!, reload?, reloaded!, #save, #save!, #save_attribute, #save_changed_interface_attributes, #save_interface_attribute, #set_relationship, #validate, #write_attribute
Methods included from AbstractModel::Validatable
#__validates_extract_options, #add_error, #clear_errors, #errors, #errors_on, #full_error_messages, #valid?, #validate, #validates_format_of, #validates_inclusion_of, #validates_numericality_of, #validates_presence_of
Methods included from AbstractModel::Relatable
#destroy_relationship, #destroy_relationships, #has_relationship?, included, #lazy_relationship?, #loaded_relationship?, #populate_relationship, #populate_relationships, #read_relationship, #relationship_class, #relationship_data, #save_relationship, #save_relationships, #set_relationship
Methods included from AbstractModel::VersionMatcher
#assert_version_match, #split_version, #version_match?
Methods included from AbstractModel::Dirty
#changed?, #changes, #clear_dirty!, #ignore_dirty, #method_missing, #set_dirty!
Methods included from AbstractModel::InterfaceAttributes
#load_interface_attribute, #load_interface_attributes, #save_interface_attribute, #save_interface_attributes, #spec_to_proc
Methods included from AbstractModel::Attributable
#attributes, #has_attribute?, included, #lazy_attribute?, #loaded_attribute?, #populate_attributes, #read_attribute, #readonly_attribute?, #write_attribute
Methods included from Logger
included, #logger, #logger_output=
Constructor Details
#initialize(ivsd) ⇒ VirtualSystemDescription
Returns a new instance of VirtualSystemDescription.
20 21 22 23 |
# File 'lib/virtualbox/virtual_system_description.rb', line 20 def initialize(ivsd) write_attribute(:interface, ivsd) initialize_attributes(ivsd) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class VirtualBox::AbstractModel::Dirty
Class Method Details
.populate_relationship(caller, data) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/virtualbox/virtual_system_description.rb', line 9 def populate_relationship(caller, data) result = Proxies::Collection.new(caller) data.each do |vsd| result << new(vsd) end result end |
Instance Method Details
#initialize_attributes(ivsd) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/virtualbox/virtual_system_description.rb', line 25 def initialize_attributes(ivsd) # Grab all the descriptions, iterate over each, and add to the hash of # descriptions. This multiple loop method is used instead of `get_description` since # that method doesn't work well with MSCOM. COM::Util.versioned_interface(:VirtualSystemDescriptionType).each_with_index do |type, index| COM::Util.versioned_interface(:VirtualSystemDescriptionValueType).each_with_index do |value_type, value_index| value = ivsd.get_values_by_type(type, value_type) if value && value != [] && value != [nil] descriptions[type] ||= {} descriptions[type][value_type] = value.first end end end # Clear dirtiness, since this should only be called initially and # therefore shouldn't affect dirtiness clear_dirty! # But this is an existing record existing_record! end |