document_hash 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module DocumentHash
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/document_hash.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "set"
1
2
  require "document_hash/version"
2
3
 
3
4
  module DocumentHash
@@ -45,6 +46,16 @@ module DocumentHash
45
46
  values.select{|v| v.is_a? self.class }.each{ |v| v.reset! }
46
47
  end
47
48
 
49
+ def merge other
50
+ self.class.symbolize_keys other
51
+ super other
52
+ end
53
+
54
+ def merge! other
55
+ self.class.symbolize_keys other
56
+ super other
57
+ end
58
+
48
59
  private
49
60
 
50
61
  attr_accessor :parent, :parent_key
@@ -54,7 +65,7 @@ module DocumentHash
54
65
  end
55
66
 
56
67
  def changed_attributes
57
- @changed ||= Set.new
68
+ @changed ||= ::Set.new
58
69
  end
59
70
 
60
71
  def self.symbolize_keys hash
@@ -65,7 +65,6 @@ describe DocumentHash::Core do
65
65
 
66
66
  it "converts inner hashes into DocumentHashes" do
67
67
  subject = DocumentHash::Core[ { test: { inner: "test" } } ]
68
-
69
68
  subject[:test].should be_a_kind_of DocumentHash::Core
70
69
  end
71
70
 
@@ -73,4 +72,14 @@ describe DocumentHash::Core do
73
72
  subject = DocumentHash::Core[ { "test" => "value" } ]
74
73
  subject.keys.should include :test
75
74
  end
75
+
76
+ it "merges new values converting the keys to symbols" do
77
+ subject = DocumentHash::Core.new
78
+
79
+ subject.merge! "test1" => "value"
80
+ subject.keys.should include :test1
81
+
82
+ subject = subject.merge "test2" => "value2"
83
+ subject.keys.should include :test2
84
+ end
76
85
  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.3
4
+ version: 0.0.4
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-27 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -42,14 +42,8 @@ files:
42
42
  - README.md
43
43
  - Rakefile
44
44
  - document_hash.gemspec
45
- - lib/.document.rb.swo
46
- - lib/.document.rb.swp
47
45
  - lib/document_hash.rb
48
- - lib/document_hash/.version.rb.swp
49
46
  - lib/document_hash/version.rb
50
- - spec/.spec_helper.rb.swp
51
- - spec/lib/.document_spec.rb.swo
52
- - spec/lib/.document_spec.rb.swp
53
47
  - spec/lib/document_spec.rb
54
48
  - spec/spec_helper.rb
55
49
  homepage: ''
@@ -77,8 +71,5 @@ signing_key:
77
71
  specification_version: 3
78
72
  summary: Document Object
79
73
  test_files:
80
- - spec/.spec_helper.rb.swp
81
- - spec/lib/.document_spec.rb.swo
82
- - spec/lib/.document_spec.rb.swp
83
74
  - spec/lib/document_spec.rb
84
75
  - spec/spec_helper.rb
data/lib/.document.rb.swo DELETED
Binary file
data/lib/.document.rb.swp DELETED
Binary file
Binary file
Binary file
Binary file
Binary file