Class: VirtualBox::Host

Inherits:
AbstractModel show all
Defined in:
lib/virtualbox/host.rb

Overview

Represents information about the host machine. This includes information such as memory available, processors, dvds, network interfaces, etc.

This information is different from system properties in that some parts represent data which is stored in the VirtualBox “registry” (such as the dvd drives, host only network interfaces, etc.)

Class Method Summary collapse

Instance Method Summary collapse

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_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(caller, raw) ⇒ Host

Initializes the system properties object. This shouldn’t be called directly. Instead ‘Global#system_properties` should be used to retrieve this object.



45
46
47
# File 'lib/virtualbox/host.rb', line 45

def initialize(caller, raw)
  initialize_attributes(caller, raw)
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) ⇒ SystemProperties

Populates the system properties relationship for anything which is related to it.

**This method typically won’t be used except internally.**

Returns:



29
30
31
# File 'lib/virtualbox/host.rb', line 29

def populate_relationship(caller, data)
  new(caller, data)
end

.save_relationship(caller, item) ⇒ Object

Saves the relationship. This simply calls #save on the relationship object.

**This method typically won’t be used except internally.**



37
38
39
# File 'lib/virtualbox/host.rb', line 37

def save_relationship(caller, item)
  item.save
end

Instance Method Details

#initialize_attributes(caller, raw) ⇒ Object

Initializes the attributes of an existing shared folder.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/virtualbox/host.rb', line 50

def initialize_attributes(caller, raw)
  # Save the interface and parent
  write_attribute(:parent, caller)
  write_attribute(:interface, raw)

  # Load the attributes from the interface
  load_interface_attributes(interface)

  # Get the relationships setup
  populate_relationship(:network_interfaces, interface)

  # Clear dirty and mark as existing
  clear_dirty!
  existing_record!
end

#saveObject

Saves the system properties.



67
68
69
# File 'lib/virtualbox/host.rb', line 67

def save
  save_changed_interface_attributes(interface)
end