couchpillow 0.3.6 → 0.3.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21f0b849af1755218e29ca407bff811b318741a2
4
- data.tar.gz: 097bf457abfa7bb1b361f7350441be8e2cafe48b
3
+ metadata.gz: e8d1a9b1e1c0a5043f07017b455ec96f31830800
4
+ data.tar.gz: 96e4d51f5aaf2e8f38cb0c5e1092514560c51544
5
5
  SHA512:
6
- metadata.gz: 1544ce8e28dcee47798cf60a5be7de8b36601d6d0318a3babd7ae692f84d9333d6996519ddd436c012a38ea176274064eb563935705c9b4a93cff8afe2d6304e
7
- data.tar.gz: 5ed40eb94d090f10ffd4996b350c274eb2e02f1992aec5060fcd25b433c58c6209c74fc4cb7e4042832bd4380fd3bc95e137fa17fe0ba26ee55779cd9ffad718
6
+ metadata.gz: 4d61133ab2fc75c1233e623f9c650038ada2f9b783625c5e245df56f671aad0eaa3c4ef76bf96ed6beaea22cd1ad86355d40f8713a21a2bef96ac02aae1c33fe
7
+ data.tar.gz: 152f3eb87627b85497698277b26a46f19a3af229d6c955aef296f83a6c016d264ec850f6a8db0b6b1b3be085c8b341526f2233b8bedbeeb338d1b3ec12034aa5
@@ -107,6 +107,17 @@ module CouchPillow
107
107
  end
108
108
 
109
109
 
110
+ # Updates the attributes in the document.
111
+ # Existing attributes will be overwritten and new ones will be added.
112
+ # Existing attributes that are not present in the hash will be ignored.
113
+ #
114
+ def update hash
115
+ hash.each do |k,v|
116
+ @data[k.to_sym] = v
117
+ end
118
+ end
119
+
120
+
110
121
  def to_json *a
111
122
  to_hash.to_json(*a)
112
123
  end
@@ -1,5 +1,5 @@
1
1
  module CouchPillow
2
2
  GEM_NAME = "couchpillow"
3
3
  NAME = "CouchPillow"
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
@@ -48,6 +48,38 @@ class TestDocument < Minitest::Test
48
48
  end
49
49
 
50
50
 
51
+ def test_update
52
+ d = Class.new(Document) do
53
+ type 'test'
54
+ end.new
55
+ hash = {
56
+ 'me' => 'too',
57
+ :batman => 'robin',
58
+ 'apple' => 123
59
+ }
60
+ d.update(hash)
61
+ assert_equal 'too', d[:me]
62
+ assert_equal 'robin', d[:batman]
63
+ assert_equal 123, d[:apple]
64
+ assert d.save!
65
+ end
66
+
67
+
68
+ def test_update_existing_fields
69
+ d = Class.new(Document) do
70
+ type 'test'
71
+ end.new({ a: 1, b: 2})
72
+ assert_equal 1, d[:a]
73
+ hash = {
74
+ 'a' => 'too',
75
+ }
76
+ d.update(hash)
77
+ assert_equal 'too', d[:a]
78
+ assert_equal 2, d[:b]
79
+ assert d.save!
80
+ end
81
+
82
+
51
83
  def test_validate_presence
52
84
  d = Class.new(Document) do
53
85
  validate_presence :xyz
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchpillow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Tedja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -88,8 +88,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.4.1
91
+ rubygems_version: 2.4.2
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Document wrapper for Couchbase
95
95
  test_files: []
96
+ has_rdoc: