Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/bitlyr/lib/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject



13
14
15
# File 'lib/bitlyr/lib/core_ext/hash.rb', line 13

def stringify_keys
  dup.stringify_keys!
end

#stringify_keys!Object



6
7
8
9
10
11
# File 'lib/bitlyr/lib/core_ext/hash.rb', line 6

def stringify_keys!
  keys.each do |key|
    self[key.to_s] = delete(key)
  end
  self
end

#symbolize_keysObject



24
25
26
# File 'lib/bitlyr/lib/core_ext/hash.rb', line 24

def symbolize_keys
  dup.symbolize_keys!
end

#symbolize_keys!Object



17
18
19
20
21
22
# File 'lib/bitlyr/lib/core_ext/hash.rb', line 17

def symbolize_keys!
  keys.each do |key|
    self[(key.to_sym rescue key) || key] = delete(key)
  end
  self
end

#to_queryObject



2
3
4
# File 'lib/bitlyr/lib/core_ext/hash.rb', line 2

def to_query
  map {|k, v|"#{k}=#{v}"}.sort * '&'
end