Module: Fog::Hyperv::ModelIncludes
- Included in:
- Compute::Hyperv::Server, Model
- Defined in:
- lib/fog/model.rb
Instance Method Summary collapse
- #cluster ⇒ Object
- #computer ⇒ Object
- #dirty? ⇒ Boolean
- #lazy_attributes ⇒ Object
- #parent ⇒ Object
- #vm ⇒ Object
Instance Method Details
#cluster ⇒ Object
47 48 49 50 51 |
# File 'lib/fog/model.rb', line 47 def cluster if @cluster || (respond_to?(:cluster_name) && cluster_name) @cluster ||= service.clusters.get cluster_name end end |
#computer ⇒ Object
41 42 43 44 45 |
# File 'lib/fog/model.rb', line 41 def computer if @computer || (respond_to?(:computer_name) && computer_name) @computer ||= service.hosts.get computer_name end end |
#dirty? ⇒ Boolean
15 16 17 18 19 |
# File 'lib/fog/model.rb', line 15 def dirty? attributes.reject do |k, v| !self.class.attributes.include?(k) || lazy_attributes.include?(k) || (old ? old.attributes[k] == v : false) end.any? end |
#lazy_attributes ⇒ Object
11 12 13 |
# File 'lib/fog/model.rb', line 11 def lazy_attributes self.class.respond_to?(:lazy_attributes) ? self.class.lazy_attributes : [] end |
#parent ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/model.rb', line 21 def parent return @vm if @vm return @computer if @computer return @cluster if @cluster return nil unless collection return collection.vm if collection.attributes.include? :vm return collection.computer if collection.attributes.include? :computer @parent ||= begin r = service.servers.get vm_name if attributes.include? :vm_name r = service.hosts.get computer_name if attributes.include? :computer_name r end end |
#vm ⇒ Object
35 36 37 38 39 |
# File 'lib/fog/model.rb', line 35 def vm if respond_to?(:vm_name) && vm_name @vm ||= service.servers.get vm_name end end |