smooth_operator 1.10.15 → 1.10.16

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjZkODA4OWRkN2I5MTEwZjQ2ZThiZjU5NjViMTg0OWRkY2ZkOTIzMg==
4
+ M2VlMDMwZTU0ODVjZTdiZTg2YmY1NDYzODE4MDVkYjlhOWJlZjliYQ==
5
5
  data.tar.gz: !binary |-
6
- ZDE1NmUwMWUxOWFlOGRlYmY1ZjM1ZWFlMTIxY2RiNzQ3NzU1ZDIxMw==
6
+ ZDg4ZGQ5NmM5MWFkYWMwYzBjYTQxZTg2ODYwOGY5OWFkZDI3ZjdkNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjE0NDA4NDNlNzFiN2EyNjUxZTY4NWNlZDg5YmM5NjgyMjhmMWNmNWYyMDdk
10
- NDA0MDljOGI1YzczMTlhNTE0MzYxYjIxOWJjMmJiNTFhZDAzYzMyZGM1OGYx
11
- NjZhYTU5Y2FlNjZkZmUzNGUxYjhlZGE2NTAzYWUwYjg4YzQwODQ=
9
+ ZjZiYjExYmU3MzdjODRjNmIxNjdhMGJkMzM3M2YzOTk3NzQ3OTAzYTAyNWU4
10
+ MWE5YjU3MWUyYjAwMmYwN2M3YzE3MTM2NDJmNzNhMTI2ZThlNjljZTM5MmZh
11
+ OWQzNzE1OWQ1OGE0MDYxNTcxN2M1NWEwN2E1MmZmNWZmNTU4ODQ=
12
12
  data.tar.gz: !binary |-
13
- MWExOWNjNzZlYjhlZWRjN2UyZDFmODNlZTAyMGE0MWM5M2EyYTBjNmZjYzBj
14
- Yzg3MDI5ZDU1MDJjMjhmNDg2NzQxYzQ3YWM0ZDgwZjdmYTQ3N2ExNTMyMTY3
15
- ZDM3OTY3YWU3Yjg3ZGRjYjY1ZTI0Y2EwNGU4NjI4ZjVjYzlhODg=
13
+ MGJjMzMxZmM0YmFkYmRlMGZiNmZlNGIzMWJlZGM4ZTQ4ZjUwM2E5ZDRlODUy
14
+ MzE1YWYwODZmYmE5MDUxZjYzZTVhNmM5YmVmZTdlYTQzY2EzMmIwNjE1NTA1
15
+ YTRkZDc2OGJkNjdkM2U5NmFjN2E4NmJkY2Y4NjA1MjA5NmM0ZWM=
data/console.rb CHANGED
@@ -25,5 +25,7 @@ LocalhostServer.new(TestServer.new, 4567)
25
25
  #user = UserWithAddressAndPosts::Son.new(FactoryGirl.attributes_for(:user_with_address_and_posts))
26
26
  #user.save('', { status: 200 })
27
27
 
28
+ # "[{\"patient_id\"=>33, \"messages\"=>[{\"id\"=>\"53722c20cb38247c36000003\", \"title\"=>\"Joao Goncalves\", \"created_at\"=>\"2014-05-13T14:28:48Z\"}, {\"id\"=>\"53722bfccb382485d5000002\", \"title\"=>\"Joao Goncalves\", \"created_at\"=>\"2014-05-13T14:28:12Z\"}, {\"id\"=>\"53722b91cb3824e913000001\", \"title\"=>\"Joao Goncalves\", \"created_at\"=>\"2014-05-13T14:26:25Z\"}]}]"
29
+
28
30
  binding.pry
29
31
 
@@ -21,13 +21,13 @@ module SmoothOperator
21
21
 
22
22
  protected #################### PROTECTED ##################
23
23
 
24
- def build_object(parsed_response, options)
24
+ def build_object(parsed_response, options, from_array = false)
25
25
  options ||={}
26
26
 
27
27
  if parsed_response.is_a?(Array)
28
- parsed_response.map { |array_entry| build_object(array_entry, options) }
28
+ parsed_response.map { |array_entry| build_object(array_entry, options, true) }
29
29
  elsif parsed_response.is_a?(Hash)
30
- if parsed_response.include?(table_name)
30
+ if !from_array && parsed_response.include?(table_name)
31
31
  ArrayWithMetaData.new(parsed_response, self)
32
32
  else
33
33
  new(parsed_response, from_server: true)
@@ -1,3 +1,3 @@
1
1
  module SmoothOperator
2
- VERSION = "1.10.15"
2
+ VERSION = "1.10.16"
3
3
  end
@@ -89,6 +89,19 @@ describe SmoothOperator::FinderMethods do
89
89
  users.each { |user| expect(user).to be_instance_of(subject) }
90
90
  end
91
91
  end
92
+
93
+ context "when the server returns an array with nested object on each entry, with the same name has the resource", current: true do
94
+ it "it should return a RemoteCall instance an instance of ArrayWithMetaData" do
95
+ remote_call = subject.find('with_metadata')
96
+ users = remote_call.data
97
+
98
+ expect(users).to be_instance_of(SmoothOperator::ArrayWithMetaData)
99
+ expect(users.page).to be(1)
100
+ expect(users.total).to be(6)
101
+ users.each { |user| expect(user).to be_instance_of(subject) }
102
+ end
103
+ end
104
+
92
105
  end
93
106
 
94
107
  end
@@ -45,12 +45,25 @@ class TestServer < Sinatra::Base
45
45
  json users
46
46
  end
47
47
 
48
+ get '/users/array_with_nested_users' do
49
+ nested_users = [{ id: 1, first_name: '1' }, { id: 2, first_name: '2' }]
50
+
51
+ users = [{ id: 1, users: nested_users}, { id: 2, users: nested_users}]
52
+
53
+ json users
54
+ end
55
+
48
56
  get '/users/misc_array' do
49
57
  json [FactoryGirl.attributes_for(:user_with_address_and_posts), 2]
50
58
  end
51
59
 
52
60
  get '/users/with_metadata' do
53
- data = { page: 1, total: 6, users: [{ id: 1 }, { id: 2 }] }
61
+ nested_users = [{ id: 1, first_name: '1' }, { id: 2, first_name: '2' }]
62
+
63
+ users = [{ id: 1, users: nested_users}, { id: 2, users: nested_users}]
64
+
65
+ data = { page: 1, total: 6, users: users }
66
+
54
67
  json data
55
68
  end
56
69
 
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.10.15
4
+ version: 1.10.16
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-05-12 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler