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 +4 -4
- data/lib/couchpillow/document.rb +11 -0
- data/lib/couchpillow/version.rb +1 -1
- data/test/test_document.rb +32 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8d1a9b1e1c0a5043f07017b455ec96f31830800
|
4
|
+
data.tar.gz: 96e4d51f5aaf2e8f38cb0c5e1092514560c51544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d61133ab2fc75c1233e623f9c650038ada2f9b783625c5e245df56f671aad0eaa3c4ef76bf96ed6beaea22cd1ad86355d40f8713a21a2bef96ac02aae1c33fe
|
7
|
+
data.tar.gz: 152f3eb87627b85497698277b26a46f19a3af229d6c955aef296f83a6c016d264ec850f6a8db0b6b1b3be085c8b341526f2233b8bedbeeb338d1b3ec12034aa5
|
data/lib/couchpillow/document.rb
CHANGED
@@ -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
|
data/lib/couchpillow/version.rb
CHANGED
data/test/test_document.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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:
|