Sha256: ddb9c6565b0d6656840ff10bde54f4db6126b34b7b32f04db7d3bec977e485ce

Contents?: true

Size: 1.18 KB

Versions: 51

Compression:

Stored size: 1.18 KB

Contents

module Beefcake
  class Buffer

    def initialize(buf='')
      if buf.respond_to?(:force_encoding)
        self.buf = buf.force_encoding('BINARY')
      else
        self.buf = buf
      end
    end

    def append_string(s)
      append_uint64(s.length)
      if s.respond_to?(:force_encoding)
        self << s.force_encoding('BINARY')
      else
        self << s
      end
    end

    alias :append_bytes :append_string

  end
end

# https://raw.github.com/Offirmo/hash-deep-merge/master/lib/hash_deep_merge.rb
class Hash

  def deep_merge!(specialized_hash)
    internal_deep_merge!(self, specialized_hash)
  end


  def deep_merge(specialized_hash)
    internal_deep_merge!(Hash.new.replace(self), specialized_hash)
  end


  protected

  def internal_deep_merge!(source_hash, specialized_hash)
    specialized_hash.each_pair do |rkey, rval|
      if source_hash.has_key?(rkey) then
        if rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then
          internal_deep_merge!(source_hash[rkey], rval)
        elsif rval == source_hash[rkey] then
        else
          source_hash[rkey] = rval
        end
      else
        source_hash[rkey] = rval
      end
    end

    source_hash
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
riemann-babbler-2.8.5 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.8.4 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.8.3 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.8.2 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.8.1 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.8.0 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.6.0 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.9 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.8 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.7 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.6 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.5 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.4 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.3 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.2 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.1 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.5.0 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.1.5 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.1.4 lib/riemann/babbler/monkey_patches.rb
riemann-babbler-2.1.3.2 lib/riemann/babbler/monkey_patches.rb