lhs 7.2.2 → 7.2.3
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 +4 -4
- data/README.md +16 -0
- data/lib/lhs/concerns/item/validation.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/item/validation_spec.rb +16 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 472c0308bceb0d57beb2999ddf90b98881ee9b2c
|
4
|
+
data.tar.gz: 3b100b77107bafa8eec978370e98ece0b0103dc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/lhs/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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
|