document_hash 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,18 @@ module DocumentHash
55
55
  self
56
56
  end
57
57
 
58
+ def to_hash
59
+ Hash[
60
+ self.collect do |k,v|
61
+ if v.is_a? DocumentHash::Core
62
+ [ k, v.to_hash ]
63
+ else
64
+ [ k, v ]
65
+ end
66
+ end
67
+ ]
68
+ end
69
+
58
70
  private
59
71
 
60
72
  attr_accessor :parent, :parent_key
@@ -84,5 +96,6 @@ module DocumentHash
84
96
  hash[(key.to_sym rescue key) || key] = hash.delete(key)
85
97
  end
86
98
  end
99
+
87
100
  end
88
101
  end
@@ -1,3 +1,3 @@
1
1
  module DocumentHash
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -135,4 +135,15 @@ describe DocumentHash::Core do
135
135
  subject[:inner][:attribute].should == "hola"
136
136
  end
137
137
 
138
+ it "converts itself to a hash", focus:true do
139
+ subject = DocumentHash::Core[{ test: "test" }]
140
+ hash = subject.to_hash
141
+ hash.should be_an_instance_of Hash
142
+ end
143
+
144
+ it "converts internal hashes to hash", focus: true do
145
+ subject = DocumentHash::Core[{ test: { inner: "value" } }]
146
+ hash = subject.to_hash
147
+ hash[:test].should be_an_instance_of Hash
148
+ end
138
149
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: document_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: