rest-in-peace 6.0.0 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/VERSION +1 -1
- data/lib/rest_in_peace/active_model_api.rb +4 -2
- data/lib/rest_in_peace.rb +11 -2
- data/spec/rest_in_peace/active_model_api_spec.rb +7 -1
- data/spec/rest_in_peace_spec.rb +2 -5
- 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: e98b14147b5fcaa949f2522f9a7a94604dd48392
|
4
|
+
data.tar.gz: 4a7ca2772da4332011de1e51da52f5bbad82335f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad31db6d17f015d3a01ef7b240f838a1579d60821cae3c06d0408118b613153a0940c259014fa3bdf0a86b2a7646a1923242166be89d5b6a84fa32e7f242400
|
7
|
+
data.tar.gz: 1bddaf47d37675233bbc2f891a344c85ceec7e0a088a44e85942648a11bf16eb32c851bf56bef66f67ed639c7b9a302ae077a344900d24815df3ae003bf55a26
|
data/README.md
CHANGED
@@ -255,3 +255,11 @@ Faraday.new do |faraday|
|
|
255
255
|
# ...
|
256
256
|
end
|
257
257
|
```
|
258
|
+
|
259
|
+
## About
|
260
|
+
|
261
|
+
This gem is currently maintained and funded by [nine.ch](https://nine.ch).
|
262
|
+
|
263
|
+
[![nine.ch](https://blog.nine.ch/assets/logo.png)](https://nine.ch)
|
264
|
+
|
265
|
+
We run your Linux server infrastructure – without interruptions, around the clock.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.0.
|
1
|
+
6.0.2
|
@@ -63,8 +63,10 @@ module RESTinPeace
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def errors=(new_errors)
|
66
|
-
new_errors.each do |
|
67
|
-
errors.
|
66
|
+
new_errors.each do |field, errors|
|
67
|
+
errors.each do |error|
|
68
|
+
self.errors.add(field.to_sym, error)
|
69
|
+
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
data/lib/rest_in_peace.rb
CHANGED
@@ -3,7 +3,6 @@ require 'active_support/core_ext/hash/indifferent_access'
|
|
3
3
|
require 'rest_in_peace/definition_proxy'
|
4
4
|
|
5
5
|
module RESTinPeace
|
6
|
-
|
7
6
|
def self.included(base)
|
8
7
|
base.send :extend, ClassMethods
|
9
8
|
base.send :include, ActiveModel::Dirty
|
@@ -25,7 +24,7 @@ module RESTinPeace
|
|
25
24
|
hash_representation[key.to_sym] = hash_representation_of_object(value)
|
26
25
|
end
|
27
26
|
else
|
28
|
-
hash_representation.merge!
|
27
|
+
hash_representation.merge!(to_write_only_hash)
|
29
28
|
end
|
30
29
|
|
31
30
|
if self.class.rip_namespace
|
@@ -56,9 +55,11 @@ module RESTinPeace
|
|
56
55
|
|
57
56
|
def to_h
|
58
57
|
hash_representation = {}
|
58
|
+
|
59
59
|
self.class.rip_attributes.values.flatten.each do |attr|
|
60
60
|
hash_representation[attr] = send(attr)
|
61
61
|
end
|
62
|
+
|
62
63
|
hash_representation
|
63
64
|
end
|
64
65
|
|
@@ -111,4 +112,12 @@ module RESTinPeace
|
|
111
112
|
}
|
112
113
|
end
|
113
114
|
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def to_write_only_hash
|
119
|
+
self.class.rip_attributes[:write].inject({}) do |h, attr|
|
120
|
+
h.merge(attr => send(attr))
|
121
|
+
end
|
122
|
+
end
|
114
123
|
end
|
@@ -176,7 +176,7 @@ describe RESTinPeace do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
let(:description) { 'desc' }
|
179
|
-
let(:errors)
|
179
|
+
let(:errors) { { description: ['must not be empty'] } }
|
180
180
|
|
181
181
|
specify { expect(instance).to respond_to(:read_attribute_for_validation).with(1).argument }
|
182
182
|
specify { expect(instance.read_attribute_for_validation(:description)).to eq('desc') }
|
@@ -187,6 +187,12 @@ describe RESTinPeace do
|
|
187
187
|
|
188
188
|
describe '#errors=' do
|
189
189
|
specify { expect { instance.errors = errors }.to change { instance.errors.count } }
|
190
|
+
|
191
|
+
it 'correctly adds the error to the instance' do
|
192
|
+
instance.errors = errors
|
193
|
+
|
194
|
+
expect(instance.errors[:description]).to eq(['must not be empty'])
|
195
|
+
end
|
190
196
|
end
|
191
197
|
|
192
198
|
describe '#valid?' do
|
data/spec/rest_in_peace_spec.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rest_in_peace'
|
2
2
|
|
3
3
|
describe RESTinPeace do
|
4
|
-
|
5
4
|
let(:extended_class) do
|
6
5
|
Class.new do
|
7
6
|
include RESTinPeace
|
8
7
|
|
8
|
+
attr_writer :relation
|
9
|
+
|
9
10
|
rest_in_peace do
|
10
11
|
attributes do
|
11
12
|
read :id, :name, :relation
|
@@ -17,10 +18,6 @@ describe RESTinPeace do
|
|
17
18
|
'something else'
|
18
19
|
end
|
19
20
|
|
20
|
-
def relation=(v)
|
21
|
-
@relation = v
|
22
|
-
end
|
23
|
-
|
24
21
|
def self_defined_method
|
25
22
|
puts 'yolo'
|
26
23
|
end
|
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: 6.0.
|
4
|
+
version: 6.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raffael Schmid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|