Module: Fog::Kubevirt::Compute::Shared
Defined Under Namespace
Classes: EntityCollection
Instance Method Summary collapse
-
#deep_merge!(source_hash, other_hash, &block) ⇒ Object
Copied from rails: File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 21 The method was changed to look like this in v4.0.0 of rails.
-
#object_to_hash(object) ⇒ Object
converts kubeclient objects into hash for fog to consume.
Instance Method Details
#deep_merge!(source_hash, other_hash, &block) ⇒ Object
Copied from rails: File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 21 The method was changed to look like this in v4.0.0 of rails
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fog/kubevirt/compute/compute.rb', line 115 def deep_merge!(source_hash, other_hash, &block) other_hash.each_pair do |current_key, other_value| this_value = source_hash[current_key] source_hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash) this_value = deep_merge!(this_value, other_value, &block) else if block_given? && key?(current_key) block.call(current_key, this_value, other_value) else other_value end end end source_hash end |
#object_to_hash(object) ⇒ Object
converts kubeclient objects into hash for fog to consume
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/fog/kubevirt/compute/compute.rb', line 97 def object_to_hash(object) result = object case result when OpenStruct result = result.marshal_dump result.each do |k, v| result[k] = object_to_hash(v) end when Array result = result.map { |v| object_to_hash(v) } end result end |