GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
put Hash utility methods in a module for mixinifying
automatthew (author)
Tue Jun 24 14:54:10 -0700 2008
commit  fcd76f8538d3e9a4cbf3738753cbf2eba3a0ed2c
tree    d995ad83b03104c9a7eb86fb03f89e502775087e
parent  e2d47eed29c1c291b6e6a12277f521f0d3031478
...
1
2
3
4
5
6
7
8
 
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
12
13
14
15
 
 
 
 
 
 
 
 
 
16
17
18
19
 
20
21
 
 
22
23
...
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
 
 
 
 
 
15
16
17
18
19
20
21
22
23
24
25
 
26
27
28
 
29
30
31
32
0
@@ -1,22 +1,31 @@
0
-class Hash
0
-
0
- def stringify_keys
0
- inject({}) do |options, (key, value)|
0
- options[key.to_s] = value
0
- options
0
- end
0
- end
0
+module Waves
0
+ module Utilities # :nodoc:
0
+
0
+ # Utility methods mixed into Hash.
0
+ module Hash
0
+
0
+ # Return a copy of the hash where all keys have been converted to strings.
0
+ def stringify_keys
0
+ inject({}) do |options, (key, value)|
0
+ options[key.to_s] = value
0
+ options
0
+ end
0
+ end
0
 
0
- # Destructively convert all keys to symbols.
0
- def symbolize_keys!
0
- keys.each do |key|
0
- unless key.is_a?(Symbol)
0
- self[key.to_sym] = self[key]
0
- delete(key)
0
+ # Destructively convert all keys to symbols.
0
+ def symbolize_keys!
0
+ keys.each do |key|
0
+ unless key.is_a?(Symbol)
0
+ self[key.to_sym] = self[key]
0
+ delete(key)
0
+ end
0
+ end
0
+ self
0
       end
0
     end
0
- self
0
   end
0
+end
0
 
0
-
0
+class Hash # :nodoc:
0
+ include Waves::Utilities::Hash
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.