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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 807b3d67a184082e23ea845cf436102917c7894e
4
- data.tar.gz: 6e2e13986dc9d6dbe31d50d10c2d3a58280c3b2c
3
+ metadata.gz: e98b14147b5fcaa949f2522f9a7a94604dd48392
4
+ data.tar.gz: 4a7ca2772da4332011de1e51da52f5bbad82335f
5
5
  SHA512:
6
- metadata.gz: e72125f7170a70ddc75b8b52969220c95acc88e200abc1385f4ada20fe15652c2d119254591d52c9f12d7bde554c16fb3f12c16b0e2811987369544e35aac18e
7
- data.tar.gz: 4bdbf8642e0b2a5b99ad02d0eae424efd8258b919518d9df6f77528d059c4685059fe380776172fe11c66e01a21d267fb52a59476637fbc9611ffa85140fb1cd
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.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 |key, value|
67
- errors.add(key.to_sym, [value].flatten)
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! to_h.keep_if { |key| write_attribute?(key) }
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) { { description: ['must not be empty'] } }
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
@@ -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.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: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel