class Hash

Hash extensions

Monkey patch string with some useful methods

Public Instance Methods

clone() click to toggle source

Do a deep copy on the object

# File lib/nub/core.rb, line 108
def clone
  hash = {}
  self.each{|k, v| hash[k] = v.clone }
  return hash
end
deep_merge(other) click to toggle source

Deep merge hash with other @param other [Hash] other hash to merge with

# File lib/nub/hash.rb, line 27
def deep_merge(other)
  merge(other){|k, av, bv|
    if av.is_a?(Hash) && bv.is_a?(Hash)
      av.deep_merge(bv)
    else
      bv
    end
  }
end
deep_merge!(other) click to toggle source

Deep merge hash with other @param other [Hash] other hash to merge with

# File lib/nub/hash.rb, line 39
def deep_merge!(other)
  merge!(other){|k, av, bv|
    if av.is_a?(Hash) && bv.is_a?(Hash)
      av.deep_merge!(bv)
    else
      bv
    end
  }
end
erb(vars = {}) click to toggle source

Easily inject ERB variables into hash values

vars

hash of variables to inject into the string

# File lib/nub/core.rb, line 116
def erb(vars = {})
  ERBResolve.new(vars).resolve(self)
end
erb!(vars = {}) click to toggle source

Easily inject ERB variables into hash values

vars

hash of variables to inject into the string

# File lib/nub/core.rb, line 122
def erb!(vars = {})
  ERBResolve.new(vars).resolve!(self)
end