hashr 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hashr (0.0.14)
4
+ hashr (0.0.15)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -77,6 +77,13 @@ class Hashr < Hash
77
77
  class << self; self end
78
78
  end
79
79
 
80
+ def to_hash
81
+ inject({}) do |hash, (key, value)|
82
+ hash[key] = value.is_a?(Hashr) ? value.to_hash : value
83
+ hash
84
+ end
85
+ end
86
+
80
87
  protected
81
88
 
82
89
  def deep_hashrize(hash)
@@ -1,3 +1,3 @@
1
1
  class Hashr < Hash
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
@@ -178,5 +178,13 @@ class HashrTest < Test::Unit::TestCase
178
178
  end
179
179
  assert_equal 5, hashr.count
180
180
  end
181
+
182
+ test 'to_hash converts the Hashr instance and all of its children to Hashes' do
183
+ hash = Hashr.new(:foo => { :bar => { :baz => 'baz' } }).to_hash
184
+
185
+ assert hash.instance_of?(Hash)
186
+ assert hash[:foo].instance_of?(Hash)
187
+ assert hash[:foo][:bar].instance_of?(Hash)
188
+ end
181
189
  end
182
190
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-15 00:00:00.000000000Z
12
+ date: 2011-09-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70171732685660 !ruby/object:Gem::Requirement
16
+ requirement: &70154104357900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70171732685660
24
+ version_requirements: *70154104357900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: test_declarative
27
- requirement: &70171732685160 !ruby/object:Gem::Requirement
27
+ requirement: &70154104357400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.0.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70171732685160
35
+ version_requirements: *70154104357400
36
36
  description: Simple Hash extension to make working with nested hashes (e.g. for configuration)
37
37
  easier and less error-prone.
38
38
  email: svenfuchs@artweb-design.de