rest-in-peace 5.1.0 → 6.0.0
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/VERSION +1 -1
- data/lib/rest_in_peace.rb +6 -1
- data/spec/rest_in_peace_spec.rb +27 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807b3d67a184082e23ea845cf436102917c7894e
|
4
|
+
data.tar.gz: 6e2e13986dc9d6dbe31d50d10c2d3a58280c3b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72125f7170a70ddc75b8b52969220c95acc88e200abc1385f4ada20fe15652c2d119254591d52c9f12d7bde554c16fb3f12c16b0e2811987369544e35aac18e
|
7
|
+
data.tar.gz: 4bdbf8642e0b2a5b99ad02d0eae424efd8258b919518d9df6f77528d059c4685059fe380776172fe11c66e01a21d267fb52a59476637fbc9611ffa85140fb1cd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.0
|
data/lib/rest_in_peace.rb
CHANGED
@@ -25,8 +25,9 @@ module RESTinPeace
|
|
25
25
|
hash_representation[key.to_sym] = hash_representation_of_object(value)
|
26
26
|
end
|
27
27
|
else
|
28
|
-
hash_representation
|
28
|
+
hash_representation.merge! to_h.keep_if { |key| write_attribute?(key) }
|
29
29
|
end
|
30
|
+
|
30
31
|
if self.class.rip_namespace
|
31
32
|
{ id: id, self.class.rip_namespace => hash_representation }
|
32
33
|
else
|
@@ -83,6 +84,10 @@ module RESTinPeace
|
|
83
84
|
object
|
84
85
|
end
|
85
86
|
|
87
|
+
def write_attribute?(attribute)
|
88
|
+
self.class.rip_attributes[:write].include?(attribute.to_sym)
|
89
|
+
end
|
90
|
+
|
86
91
|
module ClassMethods
|
87
92
|
attr_accessor :api
|
88
93
|
attr_accessor :rip_namespace
|
data/spec/rest_in_peace_spec.rb
CHANGED
@@ -143,6 +143,32 @@ describe RESTinPeace do
|
|
143
143
|
subject.payload
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
context 'all write attributes' do
|
148
|
+
specify do
|
149
|
+
expect(subject.payload(false)).to eq(
|
150
|
+
id: 1,
|
151
|
+
my_array: ['element'],
|
152
|
+
my_hash: { element1: 'yolo' },
|
153
|
+
array_with_hash: [{ element1: 'yolo' }],
|
154
|
+
overridden_attribute: 'something else',
|
155
|
+
description: 'old description'
|
156
|
+
)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'changes only' do
|
161
|
+
specify do
|
162
|
+
expect(subject.payload(true)).to eq(
|
163
|
+
id: 1,
|
164
|
+
my_array: ['element'],
|
165
|
+
my_hash: { element1: 'yolo' },
|
166
|
+
array_with_hash: [{ element1: 'yolo' }],
|
167
|
+
overridden_attribute: 'something else',
|
168
|
+
description: 'old description'
|
169
|
+
)
|
170
|
+
end
|
171
|
+
end
|
146
172
|
end
|
147
173
|
|
148
174
|
context 'with a namespace defined' do
|
@@ -152,7 +178,7 @@ describe RESTinPeace do
|
|
152
178
|
|
153
179
|
rest_in_peace do
|
154
180
|
attributes do
|
155
|
-
read :id
|
181
|
+
read :id, :relation
|
156
182
|
write :name, :description
|
157
183
|
end
|
158
184
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-in-peace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raffael Schmid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|