bosh_common/lib/common/properties/property_helper.rb
def copy_property(dst, src, name, default = nil)
      keys = name.split(".")
      src_ref = src
      dst_ref = dst

      keys.each do |key|
        src_ref = src_ref[key]
        break if src_ref.nil? # no property with this name is src
      end

      keys[0..-2].each do |key|
        dst_ref[key] ||= {}
        dst_ref = dst_ref[key]
      end

      dst_ref[keys[-1]] ||= {}
      dst_ref[keys[-1]] = src_ref.nil? ? default : src_ref
    end
# Copies property with a given name from src to dst.
# @param [Hash] dst Property destination
# @param [Hash] src Property source
# @param [String] name Property name (dot-separated)
# @param [Object] default Default value (if property is not in src)
Copies property with a given name from src to dst.
Copies property with a given name from src to dst .
def copy_property(dst, src, name, default = nil)
      keys = name.split(".")
      src_ref = src
      dst_ref = dst
      keys.each do |key|
        src_ref = src_ref[key]
        break if src_ref.nil? 
      end
      keys[0..-2].each do |key|
        dst_ref[key] ||= {}
        dst_ref = dst_ref[key]
      end
      dst_ref[keys[-1]] ||= {}
      dst_ref[keys[-1]] = src_ref.nil? ? default : src_ref
    end
def copy_property ( dst , src , name , default = nil ) keys = name . split ( "." ) src_ref = src dst_ref = dst keys . each do | key | src_ref = src_ref [ key ] break if src_ref . nil? end keys [ 0 .. - 2 ] . each do | key | dst_ref [ key ] ||= { } dst_ref = dst_ref [ key ] end dst_ref [ keys [ - 1 ] ] ||= { } dst_ref [ keys [ - 1 ] ] = src_ref . nil? ? default : src_ref end
Copies property with a given name from src to dst.
Copies property with a given name from src to dst .
# no property with this name is src
dst
src
name
default
default Default value (if property is not in src)
default Default value ( if property is not in src )