Sha256: 2a7af7918335961fc9bdfa5b24fa2d55d6d327113f3dec35011f27313ffca520

Contents?: true

Size: 379 Bytes

Versions: 16

Compression:

Stored size: 379 Bytes

Contents

class Cistern::Hash
  def self.slice(hash, *keys)
    {}.tap do |sliced|
      keys.each{ |k| sliced[k] = hash[k] if hash.key?(k) }
    end
  end

  def self.stringify_keys(object)
    case object
    when Hash
      object.inject({}){|r,(k,v)| r.merge(k.to_s => stringify_keys(v))}
    when Array
      object.map{|v| stringify_keys(v) }
    else
      object
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cistern-0.12.3 lib/cistern/hash.rb
cistern-0.12.2 lib/cistern/hash.rb
cistern-0.12.1 lib/cistern/hash.rb
cistern-0.11.3 lib/cistern/hash.rb
cistern-1.0.1.pre2 lib/cistern/hash.rb
cistern-0.11.2 lib/cistern/hash.rb
cistern-1.0.1.pre1 lib/cistern/hash.rb
cistern-1.0.0.pre lib/cistern/hash.rb
cistern-0.11.2.pre2 lib/cistern/hash.rb
cistern-0.11.1 lib/cistern/hash.rb
cistern-0.11.0 lib/cistern/hash.rb
cistern-0.10.2 lib/cistern/hash.rb
cistern-0.9.2 lib/cistern/hash.rb
cistern-0.9.1 lib/cistern/hash.rb
cistern-0.9.0 lib/cistern/hash.rb
cistern-0.8.0 lib/cistern/hash.rb