document_hash 0.0.10 → 0.0.11
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.
- data/lib/document_hash/core.rb +7 -5
- data/lib/document_hash/version.rb +1 -1
- metadata +2 -2
data/lib/document_hash/core.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module DocumentHash
|
2
2
|
class Core < Hash
|
3
|
-
def self.[]
|
4
|
-
super(
|
3
|
+
def self.[] hash, parent = nil, parent_key = nil
|
4
|
+
super(hash).tap do|new|
|
5
|
+
new.__send__ :parent=, parent if parent
|
6
|
+
new.__send__ :parent_key=, parent_key if parent_key
|
5
7
|
new.keys.each do |k|
|
6
8
|
if new[k].is_a?(Hash) && ! new[k].is_a?(self.class)
|
7
9
|
new[k] = new.class[new.delete(k)]
|
@@ -29,9 +31,7 @@ module DocumentHash
|
|
29
31
|
key = key.to_sym
|
30
32
|
|
31
33
|
if val.is_a? Hash
|
32
|
-
val = self.class[val]
|
33
|
-
val.__send__ :parent=, self;
|
34
|
-
val.__send__ :parent_key=, key;
|
34
|
+
val = self.class[val, self, key]
|
35
35
|
end
|
36
36
|
|
37
37
|
val = execute_before_change_callback key,val
|
@@ -51,6 +51,8 @@ module DocumentHash
|
|
51
51
|
|
52
52
|
def merge! other
|
53
53
|
other.each { |k, v| self[k] = v }
|
54
|
+
|
55
|
+
self
|
54
56
|
end
|
55
57
|
|
56
58
|
private
|
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.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|