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: 727bb40a1da2196809fd9c13c311d25470928e33
4
- data.tar.gz: 234f8f56226e23272ac3c9ffda941b66ca785146
3
+ metadata.gz: e8ca540f8217156b765e15258ae4183347d801e8
4
+ data.tar.gz: c4a50640b15c2c352e305a268215a2f4f4641c63
5
5
  SHA512:
6
- metadata.gz: 16f45d1fd36d5f4a5553ea34eb5e075424db0119a757bb76f953c2b2bd649e352da3879a2305ca816d0d13a00eaa46268da09a56dc6aa8eb24b8afbe85487c98
7
- data.tar.gz: a77d21a9de0aaf935f369dbe8a67c3f10856a71be3703ce5c78c626cbb140329693f49d12064a411ded5f238d3d5915bd5bfe0291739eab5c4b77b47c7fdc5bc
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 must be managed by the web server (nginx), don't enable `force_ssl` option.
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,7 +5,6 @@ module EIVO
5
5
 
6
6
  include EIVO::Concerns::Exception
7
7
  include EIVO::Concerns::Rendering
8
- include EIVO::Concerns::Pagination
9
8
 
10
9
  # doesn't work
11
10
  # rescue_from ::ActiveRecord::RecordNotFound, with: :render_not_found
@@ -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 ::ActiveModel::Type::Boolean.new.cast(params[:pagination]) == false
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
- @objects = @objects.page(params[:page]).per(limit)
22
- @serializer_options.merge!(pagination_options(@objects))
23
- end
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
- render_success serializer.new(@objects, @serializer_options)
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
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'eivo-rails-api'
5
- spec.version = '0.0.5'
5
+ spec.version = '0.0.6'
6
6
  spec.authors = ['Jonathan VUKOVICH-TRIBOUHARET']
7
7
  spec.email = ['jonathan@eivo.co']
8
8
 
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.5
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-07-31 00:00:00.000000000 Z
11
+ date: 2019-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor