lhs 7.2.2 → 7.2.3

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: 362edc3fc0fc431ab0a20d6579d13098ad00f06a
4
- data.tar.gz: 9505d7594bbdc3a073796407c257a979df0b8bcb
3
+ metadata.gz: 472c0308bceb0d57beb2999ddf90b98881ee9b2c
4
+ data.tar.gz: 3b100b77107bafa8eec978370e98ece0b0103dc5
5
5
  SHA512:
6
- metadata.gz: 9c14a4998fcbeabf8a2e0f843e72e3afea543bcfe2489b8ce37587f9ced6b7bc98f2bf9dc7fcc07da82d283d87e4600ac313bc573c6a82518cc5e5785fd26c0b
7
- data.tar.gz: 5ddebec7d8435c702ed31d157d83027a332c73fad654ec40cf281b7aca098f84f3a5af8c10ae2160a46920f50336c87310fd0ec205236bb3c4b2589789d8d805
6
+ metadata.gz: 00d83acc6b319b7e5d7b32a27eb58674f135f7afba5e9cdfde405b3e7b4f5555456583b3bae6f5cf7bc7e7cf25c27407f0e9c919a46e31984946ed2db84c60c7
7
+ data.tar.gz: c54dcd9cb6a0dbc785166b6ab3185a985767142232ff20e0cb5459ff56eb2aab3394729445d93a6b453d2f0430c1d040bf150e7fd6e95f62b867180f76c8a8c4
data/README.md CHANGED
@@ -766,6 +766,22 @@ The kaminari’s page parameter is in params[:page]. For example, you can use ka
766
766
  = paginate @items
767
767
  ```
768
768
 
769
+ ## Automatic Detection of Collections
770
+
771
+ How to configure endpoints for automatic collection detection?
772
+
773
+ LHS detects autmatically if the responded data is a single business object or a set of business objects (collection).
774
+
775
+ Conventionally, when the responds contains an `items` key `{ items: [] }` it's treated as a collection, but also if the responds contains a plain raw array: `[{ href: '' }]` it's also treated as a collection.
776
+
777
+ In case the responds uses another key than `items`, you can configure it within an `LHS::Record`:
778
+
779
+ ```ruby
780
+ class Results < LHS::Record
781
+ configuration items_key: 'docs'
782
+ end
783
+ ```
784
+
769
785
  ## form_for Helper
770
786
  Rails `form_for` view-helper can be used in combination with instances of LHS::Record to autogenerate forms:
771
787
  ```ruby
@@ -11,7 +11,7 @@ class LHS::Item < LHS::Proxy
11
11
  endpoint = validation_endpoint
12
12
  raise 'No endpoint found to perform validations! See here: https://github.com/local-ch/lhs#validation' unless endpoint
13
13
  record = LHS::Record.for_url(endpoint.url)
14
- params = merge_validation_params!(endpoint)
14
+ params = merge_validation_params!(endpoint).merge options.fetch(:params, {})
15
15
  url = validation_url(endpoint)
16
16
  run_validation!(record, options, url, params)
17
17
  true
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "7.2.2"
2
+ VERSION = "7.2.3"
3
3
  end
@@ -110,4 +110,20 @@ describe LHS::Item do
110
110
  end).to raise_error('Endpoint does not support validations!')
111
111
  end
112
112
  end
113
+
114
+ context 'generate validation url from locally passed params' do
115
+ before(:each) do
116
+ class User < LHS::Record
117
+ endpoint 'http://datastore/v2/users/:user_id', validates: { params: { persist: false } }
118
+ end
119
+ end
120
+
121
+ it 'takes local params when generating validation url' do
122
+ stub_request(:post, "http://datastore/v2/users/2?persist=false")
123
+ .to_return(status: 201)
124
+ expect(
125
+ user.valid?(params: { user_id: 2 })
126
+ ).to eq true
127
+ end
128
+ end
113
129
  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.2.2
4
+ version: 7.2.3
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-12-19 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  requirements:
377
377
  - Ruby >= 2.0.0
378
378
  rubyforge_project:
379
- rubygems_version: 2.5.2
379
+ rubygems_version: 2.6.8
380
380
  signing_key:
381
381
  specification_version: 4
382
382
  summary: Rails gem providing an easy, active-record-like interface for http json services