smooth_operator 1.21.3 → 1.21.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGI1ZGJkM2IzYmEyNDhmNjg0OGU2MDExNjExYWFmZmFiMDQ3NTVmMg==
4
+ YjNhMmMxNjM2YzRiMzY4ZGIxNzc4YzI3YTE2MTY4ZDQ1Y2MzNGRjMw==
5
5
  data.tar.gz: !binary |-
6
- ZjUzODkzZjVjNDc4YTZjZjI4ODY0YmUyNmMwYjhhMjUwYTQ0NDNlMA==
6
+ ZmE3NjZkNTExYzdhNWRlNTQ1ZTZhNDIwMDNlMDBkODQ4NmFlYmJiNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDU3MGZjZWU0YzI0MzVlYTVhMWRlM2VjMDhjYzRlN2ZjOTYzMjQ1ZGNjMTgz
10
- M2Q2NTg3Mzc4MTRiMWVhNWM5ZDcxOGM0MmM1ZTQ4OWQxYmEyNzMwZGE5NmQy
11
- ZjIxOGVmMDA0M2E5NmM2YmQxYjgzNTliZmUwYmFlOTE2NDBmZDE=
9
+ MDEwZWY2MjJhYTY2NzY2ZGQzZjVkM2I5ODBmMjk0MTI5YWZkMzNmMzM1NTkx
10
+ OGMxOTVmYjYyYTRmZjVmMjljZjk4NGYxMWNiNzkzMzAwMmQ1NjViODRkMzYw
11
+ YzMzOWRiOWQ1NDgxODc4YTRlMTk5MDllZDdlZDE3MGI4NjA4Yjg=
12
12
  data.tar.gz: !binary |-
13
- MTk5NTg5N2QzNGExZWEwYzZkOTg4MDA0ODJmMDU5ZmVkYzExYTFlMDVlNmU2
14
- ODA5ZWQxNTExMzE1OWQ0NmM1ODhiMzUxMmRiZWZkYzBiNzJhODk5YmIzMzVi
15
- MTkwMTdjNDhhMWJjZDk4YzI5MzMxZmJiOGM0OTliNWRhNTBkOGQ=
13
+ ZjllMGFlMjdhOWUyZDdiOTBkM2QyZGNhYzE0NjJkMWJiZmMwODBlMGE5YjJl
14
+ NGQ0NWRiN2E2Y2Y4NjcyMzk2NjZhNTRkY2I4NzA1ZjE4ZmExYjRjNDVkNzE2
15
+ MWI3ZTA4NDkzODE3ODk2YWMwZDJhNDljNzk0ZDY0ZDM0MmI2M2U=
data/console.rb CHANGED
@@ -31,4 +31,6 @@ post = Post.new(comments: [{ id: 1, name: '1' }, { id: 2, name: '2' }], address:
31
31
 
32
32
  comments_attributes = { "0" => { id: 1, name: '3' }, "1" => { name: '4' } }
33
33
 
34
+ comments_with_errors = { "0" => { id: 1, name: '3', errors: { body: ["can't be blank"] } }, "1" => { name: '4', errors: { body: ["can't be blank"] } } }
35
+
34
36
  binding.pry
@@ -25,11 +25,7 @@ module SmoothOperator
25
25
  attributes.each do |name, value|
26
26
  next unless allowed_attribute(name)
27
27
 
28
- if respond_to?("#{name}=")
29
- send("#{name}=", value)
30
- else
31
- internal_data_push(name, value)
32
- end
28
+ send("#{name}=", value)
33
29
  end
34
30
  end
35
31
 
@@ -54,7 +54,7 @@ module SmoothOperator
54
54
  begin
55
55
  JSON.parse(body)
56
56
  rescue JSON::ParserError
57
- nil
57
+ body
58
58
  end
59
59
  end
60
60
 
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = "1.21.3"
2
+ VERSION = "1.21.4"
3
3
  end
@@ -38,6 +38,8 @@ module SmoothOperator
38
38
  include ActiveModel::Validations::Callbacks
39
39
  include ActiveModel::Conversion
40
40
 
41
+ self.unknown_hash_class = SmoothOperator::OpenStruct
42
+
41
43
  validate :validate_induced_errors, :validate_nested_objects
42
44
 
43
45
  def column_for_attribute(attribute_name)
@@ -77,7 +79,10 @@ module SmoothOperator
77
79
  end
78
80
 
79
81
  def validate_nested_objects
80
- # nested_objects.map { |reflection, nested_object| nested_object.valid? }.all?
82
+ all_nested_objects = self.class.reflections.keys
83
+ .map { |association| send(association) }.flatten.compact
84
+
85
+ all_nested_objects.map { |nested_object| nested_object.valid? }.all?
81
86
  end
82
87
 
83
88
  end
@@ -247,7 +247,7 @@ describe SmoothOperator::RemoteCall do
247
247
 
248
248
  context "when the connection exceeds the timeout" do
249
249
  subject { User::TimeoutConnection.new }
250
-
250
+
251
251
  before { subject.save('/timeout') }
252
252
 
253
253
  it "#ok? should return false" do
@@ -291,8 +291,8 @@ describe SmoothOperator::RemoteCall do
291
291
  context "when the server response's body does not contains valid json data" do
292
292
  let(:remote_call) { User::Base.find('bad_json') }
293
293
 
294
- it "should return nil" do
295
- expect(remote_call.data).to be nil
294
+ it "it should return what the server has returned" do
295
+ expect(remote_call.data).to eq('ok')
296
296
  end
297
297
  end
298
298
  end
@@ -308,7 +308,7 @@ describe SmoothOperator::RemoteCall do
308
308
 
309
309
  context "when a server connection fails" do
310
310
  subject { User::TimeoutConnection.new }
311
-
311
+
312
312
  before { subject.save('/timeout') }
313
313
 
314
314
  it "should return 0" do
@@ -1,3 +1,5 @@
1
1
  class Comment < SmoothOperator::Base
2
2
 
3
+ self.unknown_hash_class = SmoothOperator::OpenStruct
4
+
3
5
  end
@@ -8,6 +8,8 @@ class Post < SmoothOperator::Base
8
8
 
9
9
  self.rails_serialization = true
10
10
 
11
+ self.unknown_hash_class = SmoothOperator::OpenStruct
12
+
11
13
  has_many :comments#, rails_serialization: true
12
14
 
13
15
  belongs_to :address#, rails_serialization: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_operator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.3
4
+ version: 1.21.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Gonçalves
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler