Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/chisel/ruby/hash.rb

Instance Method Summary collapse

Instance Method Details

#symbolize_keysObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/chisel/ruby/hash.rb', line 3

def symbolize_keys
	self.inject({}) do |memo,(k,v)| 
		if v.is_a?(Hash)
			memo[k.to_sym] = v.symbolize_keys
		else
			memo[k.to_sym] = v
		end
		memo
	end
end

#to_binding(object = Object.new) ⇒ Object



14
15
16
17
18
# File 'lib/chisel/ruby/hash.rb', line 14

def to_binding(object = Object.new)
	object.instance_eval("def binding_for(#{keys.join(",")}) binding end")
	# object.instance_eval('def method_missing(method_name); nil; end')
	object.binding_for(*values)
end