eivo-rails-api 0.0.5 → 0.0.6
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: e8ca540f8217156b765e15258ae4183347d801e8
|
4
|
+
data.tar.gz: c4a50640b15c2c352e305a268215a2f4f4641c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5564cdb5b805d7a14335cdae3597655481dbc5b473aa14772ccdfb73f396487e9cc62b9d431c8233fae58cd06bd81359e60ee641b34663b9b238d9f1025a3fd1
|
7
|
+
data.tar.gz: 96c282e73bec60cba58e5559b6a767828e1b0d9c25c18910406fe64abd67df5250e69fd7062734c992b3292d5aba74b18c7449a44bfaf05e32752251184e8486
|
data/README.md
CHANGED
@@ -39,7 +39,7 @@ sentry:
|
|
39
39
|
|
40
40
|
### Warning
|
41
41
|
|
42
|
-
SSL / TLS
|
42
|
+
`force_ssl` option is not enabled, for performance reasons SSL / TLS should be managed by the web server (nginx, Apache).
|
43
43
|
|
44
44
|
## License
|
45
45
|
|
@@ -5,6 +5,20 @@ module EIVO
|
|
5
5
|
module Pagination
|
6
6
|
extend ::ActiveSupport::Concern
|
7
7
|
|
8
|
+
def paginate(collection)
|
9
|
+
unless ::ActiveModel::Type::Boolean.new.cast(params[:pagination]) == false
|
10
|
+
limit = 50
|
11
|
+
if params[:limit]
|
12
|
+
limit = [[params[:limit].to_i, 1].max, 500].min
|
13
|
+
end
|
14
|
+
|
15
|
+
collection = collection.page(params[:page]).per(limit)
|
16
|
+
@serializer_options.merge!(pagination_options(collection))
|
17
|
+
end
|
18
|
+
|
19
|
+
collection
|
20
|
+
end
|
21
|
+
|
8
22
|
def pagination_options(collection)
|
9
23
|
options = {
|
10
24
|
is_collection: true,
|
@@ -5,24 +5,30 @@ module EIVO
|
|
5
5
|
module Resources
|
6
6
|
extend ::ActiveSupport::Concern
|
7
7
|
|
8
|
+
include EIVO::Concerns::Pagination
|
9
|
+
|
8
10
|
included do
|
9
11
|
before_action :set_default_serializer_options
|
10
12
|
end
|
11
13
|
|
12
|
-
def index
|
14
|
+
def index(options = {})
|
13
15
|
@objects ||= collection_index
|
14
16
|
|
15
|
-
unless
|
16
|
-
limit = 50
|
17
|
-
if params[:limit]
|
18
|
-
limit = [[params[:limit].to_i, 1].max, 500].min
|
19
|
-
end
|
17
|
+
@objects = paginate(@objects) unless options[:paginate] == false
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if options[:cache] && options[:cache] != false
|
20
|
+
if options[:cache].is_a?(Hash)
|
21
|
+
cache_options = options[:cache]
|
22
|
+
else
|
23
|
+
cache_options = {}
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
+
if stale?(@objects, public: cache_options.fetch(:public, false))
|
27
|
+
render_success serializer.new(@objects, @serializer_options)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
render_success serializer.new(@objects, @serializer_options)
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
34
|
def show
|
data/eivo-rails-api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eivo-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan VUKOVICH-TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|