simply_useful 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ nbproject/
7
7
  coverage
8
8
  pkg/
9
9
  .specification
10
+ simply_useful*.gem
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 1
3
- :patch: 5
3
+ :patch: 6
4
4
  :major: 0
data/lib/core_ext/hash.rb CHANGED
@@ -25,12 +25,19 @@ module SimplyUseful
25
25
  private
26
26
 
27
27
  def _deep_symbolize_keys(value)
28
- return value unless value.is_a?(Hash)
29
- hash = value.inject({}) do |memo,(k,v)|
30
- memo[(k.to_sym rescue k)|| k] = _deep_symbolize_keys(v)
31
- memo
28
+ if value.is_a? Hash
29
+ hash = value.inject({}) do |memo,(k,v)|
30
+ memo[(k.to_sym rescue k)|| k] = _deep_symbolize_keys(v)
31
+ memo
32
+ end
33
+ return hash
34
+ elsif value.is_a? Array
35
+ value.map do |e|
36
+ _deep_symbolize_keys(e)
37
+ end
38
+ else
39
+ value
32
40
  end
33
- return hash
34
41
  end
35
42
 
36
43
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simply_useful}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Maciej Bilas"]
@@ -17,6 +17,13 @@ describe SimplyUseful::CoreExtensions::Keys do
17
17
  te = {:a => {:b => "c"}}
18
18
  te.should == ta
19
19
  end
20
+
21
+ it "should symbolize keys in child array's hashes" do
22
+ t = {"a" => [{"b" => "c", "d" => "e"}]}
23
+ te = {:a => [{:b => "c", :d => "e"}]}
24
+ ta = t.deep_symbolize_keys
25
+ te.should == ta
26
+ end
20
27
  end
21
28
 
22
29
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Maciej Bilas