Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/open_trade/base/message.rb

Instance Method Summary collapse

Instance Method Details

#strict_update(h = {}) ⇒ Object

Update only keys that exist in self with values that exist in param



7
8
9
10
# File 'lib/open_trade/base/message.rb', line 7

def strict_update h={}
	self.keys.each {|k| self[k] = h[k] if h.has_key? k}
	self
end

#symbolize_keysObject



12
13
14
15
16
# File 'lib/open_trade/base/message.rb', line 12

def symbolize_keys
	inject({}) do |options, (key, value)| options[(key.to_sym rescue key) || key] = value
	options
	end 
end

#symbolize_keys!(recurse = false) ⇒ Object



18
19
20
21
22
23
# File 'lib/open_trade/base/message.rb', line 18

def symbolize_keys! recurse=false
	self.replace(self.symbolize_keys)
	if recurse
		self.values.each {|v| v.symbolize_keys! if v.class == self.class}
	end
end