Sha256: 249437bd76a0528bfb7e0d333f6fbcb32fec7ccc14d0cad816d9310c601a7010

Contents?: true

Size: 495 Bytes

Versions: 4

Compression:

Stored size: 495 Bytes

Contents

module CouchPillow

  def self.symbolize hash
    hash.inject({}) do |memo,(k,v)|
      memo[k.to_sym] = sanitize(v)
      memo
    end
  end


  def self.sanitize value
    sanitized = nil
    if value.class == Hash
      sanitized = {}
      value.each do |k, v|
        sanitized[k] = sanitize(v)
      end
    elsif value.class == Array
      sanitized = []
      value.each do |e|
        sanitized << sanitize(e)
      end
    else
      sanitized = value
    end
    sanitized
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couchpillow-0.4.12 lib/couchpillow/helper.rb
couchpillow-0.4.11 lib/couchpillow/helper.rb
couchpillow-0.4.10 lib/couchpillow/helper.rb
couchpillow-0.4.9 lib/couchpillow/helper.rb