module Fog::Kubevirt::Compute::Shared

Public Instance Methods

deep_merge!(source_hash, other_hash, &block) click to toggle source

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

# 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) click to toggle source

converts kubeclient objects into hash for fog to consume

# 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