lhs 7.0.1 → 7.0.2
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,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ef5524ff9e948847824a817645866f6c19e19c
|
4
|
+
data.tar.gz: 8fa5c95d922cac9de6adc95509410b475d293693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65195f7a18c36afbdebe4c8441559de59dc7252c3471ec27bf060f7b0dd880327b81cd319c46e19e8aaa6466ff5810441f788a6a148fa35e6eeabc15a6464a9d
|
7
|
+
data.tar.gz: 36fadb3d46b9531e8d8b1b46e49b12c66544f47ae5c49a203650ae80a01e53ee48bb6497845cc23dae5c159e5c77ba0f445be93bcd5c6e3c3bf3eedf6b2218fe
|
@@ -256,7 +256,7 @@ class LHS::Record
|
|
256
256
|
|
257
257
|
def resolved_options
|
258
258
|
options = chain_options
|
259
|
-
options = options.
|
259
|
+
options = options.deep_merge(params: chain_parameters.merge(chain_pagination))
|
260
260
|
options = options.merge(error_handler: chain_error_handler) if chain_error_handler.present?
|
261
261
|
options = options.merge(including: chain_includes) if chain_includes.present?
|
262
262
|
options = options.merge(referencing: chain_references) if chain_references.present?
|
@@ -22,7 +22,7 @@ class LHS::Record
|
|
22
22
|
|
23
23
|
def _find_by(params, options = {})
|
24
24
|
options ||= {}
|
25
|
-
params = params.dup.merge(limit: 1)
|
25
|
+
params = params.dup.merge(limit: 1).merge(options.fetch(:params, {}))
|
26
26
|
data = request(options.merge(params: params))
|
27
27
|
if data._proxy.is_a?(LHS::Collection)
|
28
28
|
data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
|
@@ -109,7 +109,7 @@ class LHS::Record
|
|
109
109
|
return if data.blank? || skip_loading_includes?(data, included)
|
110
110
|
options = options_for_data(data, included)
|
111
111
|
options = extend_with_references(options, references)
|
112
|
-
addition = load_include(options, data, sub_includes)
|
112
|
+
addition = load_include(options, data, sub_includes, references)
|
113
113
|
extend_raw_data!(data, addition, included)
|
114
114
|
expand_addition!(data, included) if no_expanded_data?(addition)
|
115
115
|
end
|
@@ -162,14 +162,14 @@ class LHS::Record
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Load additional resources that are requested with include
|
165
|
-
def load_include(options, data, sub_includes)
|
165
|
+
def load_include(options, data, sub_includes, references)
|
166
166
|
record = record_for_options(options) || self
|
167
167
|
options = convert_options_to_endpoints(options) if record_for_options(options)
|
168
168
|
begin
|
169
169
|
if options.is_a?(Array)
|
170
|
-
options.each { |options| options.merge!(including: sub_includes) if sub_includes.present? }
|
170
|
+
options.each { |options| options.merge!(including: sub_includes, referencing: references) if sub_includes.present? }
|
171
171
|
elsif sub_includes.present?
|
172
|
-
options.merge!(including: sub_includes)
|
172
|
+
options.merge!(including: sub_includes, referencing: references)
|
173
173
|
end
|
174
174
|
record.request(options)
|
175
175
|
rescue LHC::NotFound
|
data/lib/lhs/version.rb
CHANGED
@@ -5,7 +5,7 @@ describe LHS::Record do
|
|
5
5
|
class Record < LHS::Record
|
6
6
|
endpoint 'http://datastore/records/'
|
7
7
|
end
|
8
|
-
stub_request(:get, "http://datastore/records/?limit=1&name=Steve")
|
8
|
+
stub_request(:get, "http://datastore/records/?limit=1&name=Steve&color=blue")
|
9
9
|
.to_return(body: [{ name: 'Steve', color: 'blue' }].to_json)
|
10
10
|
end
|
11
11
|
|
@@ -407,4 +407,46 @@ describe LHS::Record do
|
|
407
407
|
expect(customers.first.places.first.id).to eq 1
|
408
408
|
end
|
409
409
|
end
|
410
|
+
|
411
|
+
context 'more complex examples' do
|
412
|
+
before(:each) do
|
413
|
+
class Place < LHS::Record
|
414
|
+
endpoint 'http://datastore/places/:id'
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'forwards complex references' do
|
419
|
+
stub_request(:get, "http://datastore/places/123?limit=1&forwarded_params=for_place")
|
420
|
+
.to_return(body: {
|
421
|
+
'contracts' => {
|
422
|
+
'href' => "http://datastore/places/123/contracts"
|
423
|
+
}
|
424
|
+
}.to_json)
|
425
|
+
stub_request(:get, "http://datastore/places/123/contracts?forwarded_params=for_contracts")
|
426
|
+
.to_return(body: {
|
427
|
+
href: "http://datastore/places/123/contracts?forwarded_params=for_contracts",
|
428
|
+
items: [
|
429
|
+
{ product: { 'href' => "http://datastore/products/llo" } }
|
430
|
+
]
|
431
|
+
}.to_json)
|
432
|
+
stub_request(:get, "http://datastore/products/llo?forwarded_params=for_product")
|
433
|
+
.to_return(body: {
|
434
|
+
'href' => "http://datastore/products/llo",
|
435
|
+
'name' => 'Local Logo'
|
436
|
+
}.to_json)
|
437
|
+
place = Place
|
438
|
+
.options(params: { forwarded_params: 'for_place' })
|
439
|
+
.includes(contracts: :product)
|
440
|
+
.references(
|
441
|
+
contracts: {
|
442
|
+
params: { forwarded_params: 'for_contracts' },
|
443
|
+
product: { params: { forwarded_params: 'for_product' } }
|
444
|
+
}
|
445
|
+
)
|
446
|
+
.find_by(id: '123')
|
447
|
+
expect(
|
448
|
+
place.contracts.first.product.name
|
449
|
+
).to eq 'Local Logo'
|
450
|
+
end
|
451
|
+
end
|
410
452
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|