Class: VirtualBox::USB
- Inherits:
-
AbstractModel
- Object
- AbstractModel
- VirtualBox::USB
- Defined in:
- lib/virtualbox/usb.rb
Overview
Represents a single USB device of a virtual machine.
Currently, new USB devices can't be created, so the only way to get this
object is through a VM's usbs
relationship.
Attributes
Properties of the model are exposed using standard ruby instance methods which are generated on the fly. Because of this, they are not listed below as available instance methods.
These attributes can be accessed and modified via standard ruby-style
instance.attribute
and instance.attribute=
methods. The attributes are
listed below. If you aren't sure what this means or you can't understand
why the below is listed, please read Attributable.
attribute :parent, :readonly => :readonly attribute :name attribute :active attribute :manufacturer attribute :product attribute :remote
Class Method Summary
- + (Array<USB>) populate_relationship(caller, doc) Populates the usb device relationship for anything which is related to it.
Instance Method Summary
- - (USB) initialize(caller, data) constructor Since there is currently no way to create a new usb device, this is only used internally.
Methods inherited from AbstractModel
#destroy, #errors, #existing_record!, #inspect, #lazy_attribute?, #lazy_relationship?, #new_record!, #new_record?, #populate_attributes, #populate_relationship, #populate_relationships, #reload!, reload!, reload?, reloaded!, #save, #save_attribute, #set_relationship, #validate, #write_attribute
Methods included from AbstractModel::Attributable
#attributes, #has_attribute?, included, #lazy_attribute?, #loaded_attribute?, #populate_attributes, #read_attribute, #readonly_attribute?, #write_attribute
Methods included from AbstractModel::Dirty
#changed?, #changes, #clear_dirty!, #ignore_dirty, #method_missing, #set_dirty!
Methods included from AbstractModel::Relatable
#destroy_relationship, #destroy_relationships, #has_relationship?, included, #lazy_relationship?, #loaded_relationship?, #populate_relationship, #populate_relationships, #read_relationship, #relationship_data, #save_relationship, #save_relationships, #set_relationship
Methods included from AbstractModel::Validatable
#add_error, #clear_errors, #errors, #valid?, #validate, #validates_presence_of
Constructor Details
- (USB) initialize(caller, data)
Since there is currently no way to create a new usb device, this is only used internally. Developers should NOT try to initialize their own usb device objects.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/virtualbox/usb.rb', line 53 def initialize(caller, data) super() # Set the parent write_attribute(:parent, caller) # Convert each attribute value to a string attrs = {} data.attributes.each do |key, value| attrs[key.to_sym] = value.to_s end populate_attributes(attrs) # Clear dirtiness clear_dirty! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class VirtualBox::AbstractModel::Dirty
Class Method Details
+ (Array<USB>) populate_relationship(caller, doc)
Populates the usb device relationship for anything which is related to it.
This method typically won't be used except internally.
39 40 41 42 43 44 45 46 47 |
# File 'lib/virtualbox/usb.rb', line 39 def populate_relationship(caller, doc) relation = Proxies::Collection.new(caller) doc.css("Hardware USBController DeviceFilter").each do |device| relation << new(caller, device) end relation end |