lhs 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lhs.gemspec +1 -1
- data/lib/lhs.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad5fddbc81ea541b51fe1b5307b773b0f4877637
|
4
|
+
data.tar.gz: 345b34a867ed7e0305aa7b36f9bc13b5f907a12b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57179b85e99d847699e2683ce84d145451a0e867764f7735815afe9ca89defec1434f2691e8c6be61aa763d07e45ffdf20f8f24e5a082a3cb1607dbdc3f8b08b
|
7
|
+
data.tar.gz: 266ede9c1a9574ab6770865635872cb68df27eefaf3fb85e9f16988cde7ef64b8889e9e8cfac2d7125e2c4ee0ee43334b8049f5a5d18e86a59cef1b96e79b95b
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ LHS uses [LHC](//github.com/local-ch/LHC) for http requests.
|
|
5
5
|
|
6
6
|
## Very Short Introduction
|
7
7
|
|
8
|
-
|
8
|
+
Access data that is provided by an http json service with ease using a LHS::Record.
|
9
9
|
|
10
10
|
```ruby
|
11
11
|
class Feedback < LHS::Record
|
@@ -25,7 +25,7 @@ Please store all defined LHS::Records in `app/models` as they are not autoloaded
|
|
25
25
|
|
26
26
|
## Endpoints
|
27
27
|
|
28
|
-
You setup a LHS::Record by configuring one or multiple
|
28
|
+
You setup a LHS::Record by configuring one or multiple endpoints. You can also add request options for an endpoint (see following example).
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
class Feedback < LHS::Record
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
|
53
53
|
## Find multiple records
|
54
54
|
|
55
|
-
You can query a
|
55
|
+
You can query a service for records by using `where`.
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
Feedback.where(has_reviews: true)
|
@@ -73,7 +73,7 @@ Uses the `:datastore/v2/content-ads/:campaign_id/feedbacks` endpoint.
|
|
73
73
|
If no record is found an error is raised.
|
74
74
|
|
75
75
|
## Proxy
|
76
|
-
Instead of mapping data when it arrives from the
|
76
|
+
Instead of mapping data when it arrives from the service, the proxy makes data accessible when you access it, not when you fetch it. The proxy is used to access data and it is divided in `Collection` and `Item`.
|
77
77
|
|
78
78
|
`find` can also be used to find a single uniqe record with parameters:
|
79
79
|
|
@@ -106,7 +106,7 @@ If no record is found, `nil` is returned.
|
|
106
106
|
|
107
107
|
**Be careful using methods for batch processing. They could result in a lot of HTTP requests!**
|
108
108
|
|
109
|
-
`all` fetches all records from the
|
109
|
+
`all` fetches all records from the service by doing multiple requests if necessary.
|
110
110
|
|
111
111
|
```ruby
|
112
112
|
data = Feedback.all
|
@@ -164,7 +164,8 @@ Build and persist new items from scratch are done either with `new` or it's alia
|
|
164
164
|
|
165
165
|
## Custom setters and getters
|
166
166
|
|
167
|
-
Sometimes it is the case that you want to have your custom getters and setters and convert the data to
|
167
|
+
Sometimes it is the case that you want to have your custom getters and setters and convert the data to a processable format behind the scenes.
|
168
|
+
The initializer will now use custom setter if one is defined:
|
168
169
|
|
169
170
|
```ruby
|
170
171
|
class Feedback < LHS::Record
|
@@ -356,7 +357,7 @@ end
|
|
356
357
|
|
357
358
|
## Collections: Offset / Limit / Pagination
|
358
359
|
|
359
|
-
You can paginate by passing offset, and limit params. They will be forwarded to the
|
360
|
+
You can paginate by passing offset, and limit params. They will be forwarded to the service.
|
360
361
|
|
361
362
|
```ruby
|
362
363
|
data = Feedback.where(limit: 50)
|
data/lhs.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ['https://github.com/local-ch/lhs/graphs/contributors']
|
11
11
|
s.email = ['ws-operations@local.ch']
|
12
12
|
s.homepage = 'https://github.com/local-ch/lhs'
|
13
|
-
s.summary = 'Rails gem providing an easy, active-record-like interface
|
13
|
+
s.summary = 'Rails gem providing an easy, active-record-like interface for http json services'
|
14
14
|
s.description = s.summary
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
data/lib/lhs.rb
CHANGED
@@ -9,7 +9,7 @@ Gem.find_files('lhs/**/*.rb').sort.each { |path| require path }
|
|
9
9
|
class Engine < Rails::Engine
|
10
10
|
initializer 'Load all LHS::Records from app/models/**' do |app|
|
11
11
|
Dir.glob(app.root.join('app/models/**/*.rb')).each do |file|
|
12
|
-
require file if File.read(file).
|
12
|
+
require file if File.read(file).match('LHS::Record')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/lhs/version.rb
CHANGED
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: 3.4.
|
4
|
+
version: 3.4.1
|
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-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -150,8 +150,8 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description: Rails gem providing an easy, active-record-like interface
|
154
|
-
|
153
|
+
description: Rails gem providing an easy, active-record-like interface for http json
|
154
|
+
services
|
155
155
|
email:
|
156
156
|
- ws-operations@local.ch
|
157
157
|
executables: []
|
@@ -329,8 +329,7 @@ rubyforge_project:
|
|
329
329
|
rubygems_version: 2.2.2
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
|
-
summary: Rails gem providing an easy, active-record-like interface
|
333
|
-
services
|
332
|
+
summary: Rails gem providing an easy, active-record-like interface for http json services
|
334
333
|
test_files:
|
335
334
|
- spec/collection/collection_items_spec.rb
|
336
335
|
- spec/collection/configurable_spec.rb
|