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
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/fog/kubevirt/compute/compute.rb', line 108 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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fog/kubevirt/compute/compute.rb', line 90 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 |