Class: Fog::Hyperv::VMCollection

Inherits:
ComputerCollection show all
Defined in:
lib/fog/collection.rb

Instance Attribute Summary collapse

Attributes inherited from ComputerCollection

#cluster, #computer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComputerCollection

requires_computer

Methods inherited from Collection

#all, #create, #get, get_method, requires, requires?

Instance Attribute Details

#vmObject

Returns the value of attribute vm.



108
109
110
# File 'lib/fog/collection.rb', line 108

def vm
  @vm
end

Class Method Details

.match_on(attr = nil) ⇒ Object



100
101
102
# File 'lib/fog/collection.rb', line 100

def self.match_on(attr = nil)
  @match_on ||= attr
end

.requires_vmObject



104
105
106
# File 'lib/fog/collection.rb', line 104

def self.requires_vm
  requires << :vm
end

Instance Method Details

#inspectObject



119
120
121
122
# File 'lib/fog/collection.rb', line 119

def inspect
  # To avoid recursing on VM
  to_s
end

#new(attributes = {}) ⇒ Object



110
111
112
113
114
115
116
117
# File 'lib/fog/collection.rb', line 110

def new(attributes = {})
  object = super
  object.computer_name ||= vm.computer_name if vm && object.respond_to?(:computer_name)
  # Ensure both ID and Name are populated, regardless of `match_on`
  object.vm_id ||= vm.id if vm && object.respond_to?(:vm_id)
  object.vm_name ||= vm.name if vm && object.respond_to?(:vm_name)
  object
end