Module: Fog::Hyperv::ModelIncludes
- Included in:
- Compute::Server, Model
- Defined in:
- lib/fog/hyperv/model.rb
Instance Method Summary collapse
-
#cluster ⇒ Fog::Hyperv::Compute::Cluster?
Get the Cluster this model is part of.
-
#computer ⇒ Fog::Hyperv::Compute::Host?
Get the Computer this model is attached to.
-
#dirty ⇒ Array<Symbol>
Get all dirty attributes.
-
#dirty? ⇒ Boolean
Has the model been modified.
-
#vm ⇒ Fog::Hyperv::Compute::Server?
Get the VM this model is attached to.
Instance Method Details
#cluster ⇒ Fog::Hyperv::Compute::Cluster?
Get the Cluster this model is part of
76 77 78 79 80 81 |
# File 'lib/fog/hyperv/model.rb', line 76 def cluster return @cluster if @cluster return unless respond_to?(:cluster_name) && cluster_name @cluster ||= service.clusters.get cluster_name end |
#computer ⇒ Fog::Hyperv::Compute::Host?
Get the Computer this model is attached to
67 68 69 70 71 72 |
# File 'lib/fog/hyperv/model.rb', line 67 def computer return @computer if @computer return @computer ||= service.hosts.get(computer_name) if respond_to?(:computer_name) && computer_name @computer ||= vm&.computer end |
#dirty ⇒ Array<Symbol>
Get all dirty attributes
49 50 51 52 53 54 |
# File 'lib/fog/hyperv/model.rb', line 49 def dirty potential = attributes.slice(*self.class.attributes) return potential unless old potential.reject { |k, v| old.attributes[k] == v }.keys end |
#dirty? ⇒ Boolean
Has the model been modified
43 44 45 |
# File 'lib/fog/hyperv/model.rb', line 43 def dirty? dirty.any? end |
#vm ⇒ Fog::Hyperv::Compute::Server?
Get the VM this model is attached to
58 59 60 61 62 63 |
# File 'lib/fog/hyperv/model.rb', line 58 def vm return @vm if @vm return unless respond_to?(:vm_id) && vm_id @vm ||= service.servers.get vm_id end |