api-pagination 4.7.1 → 4.7.2
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/lib/api-pagination/hooks.rb +15 -23
- data/lib/api-pagination/railtie.rb +19 -0
- data/lib/api-pagination/version.rb +1 -1
- data/spec/support/numbers_controller.rb +4 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd1a8e55bce363ef14c8fca2ff4a06ea1cf325e61fe2eba564d6bcbcb0cbb43
|
4
|
+
data.tar.gz: 66a8a77cc4e1fa163ce3e644c2828388778efaab24783967c2c9e7986a83ac30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475209b5986a009d9bc52cded5269fec22998e6d94c419635772950ee17ea7a1b0a01818b6791f009fe9da545022522f2ba0303a5fae93d81a364f3bc740cb1e
|
7
|
+
data.tar.gz: 355d8e7786bf49318941d48ea57ff6fd81fd6cf9b97d9e185fb1302eb20dc4144100f3fce675809d73bffc0341b0f100e37fb3f12a2e6c51ea9b98e4d9db5a03
|
data/lib/api-pagination/hooks.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
begin; require 'rails'; rescue LoadError; end
|
2
|
-
begin; require 'rails-api'; rescue LoadError; end
|
3
|
-
|
4
|
-
if defined?(Rails)
|
5
|
-
module ApiPagination
|
6
|
-
module Hooks
|
7
|
-
def self.rails_parent_controller
|
8
|
-
if Gem::Version.new(Rails.version) >= Gem::Version.new('5') || defined?(ActionController::API)
|
9
|
-
ActionController::API
|
10
|
-
else
|
11
|
-
ActionController::Base
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
require 'rails/pagination'
|
18
|
-
|
19
|
-
ActiveSupport.on_load(:action_controller) do
|
20
|
-
ApiPagination::Hooks.rails_parent_controller.send(:include, Rails::Pagination)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
1
|
begin; require 'grape'; rescue LoadError; end
|
25
2
|
if defined?(Grape::API)
|
26
3
|
require 'grape/pagination'
|
@@ -40,3 +17,18 @@ unless defined?(Kaminari) || defined?(WillPaginate::CollectionMethods)
|
|
40
17
|
WARNING
|
41
18
|
end
|
42
19
|
|
20
|
+
if defined?(Rails)
|
21
|
+
module ApiPagination
|
22
|
+
module Hooks
|
23
|
+
def self.rails_parent_controller
|
24
|
+
if Rails::VERSION::MAJOR >= 5 || defined?(ActionController::API)
|
25
|
+
ActionController::API
|
26
|
+
else
|
27
|
+
ActionController::Base
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'api-pagination/railtie'
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module ApiPagination
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer :api_pagination do
|
6
|
+
ActiveSupport.on_load(:action_controller) do
|
7
|
+
require 'rails/pagination'
|
8
|
+
|
9
|
+
klass = if Rails::VERSION::MAJOR >= 5 || defined?(ActionController::API)
|
10
|
+
ActionController::API
|
11
|
+
else
|
12
|
+
ActionController::Base
|
13
|
+
end
|
14
|
+
|
15
|
+
klass.send(:include, Rails::Pagination)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'action_controller'
|
1
|
+
require 'action_controller/railtie'
|
2
2
|
require 'api-pagination/hooks'
|
3
3
|
require 'ostruct'
|
4
4
|
|
@@ -59,7 +59,7 @@ class NumbersSerializer
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
class NumbersController <
|
62
|
+
class NumbersController < ActionController::API
|
63
63
|
include Rails.application.routes.url_helpers
|
64
64
|
|
65
65
|
def index
|
@@ -99,3 +99,5 @@ class NumbersController < ApiPagination::Hooks.rails_parent_controller
|
|
99
99
|
render json: NumbersSerializer.new(numbers)
|
100
100
|
end
|
101
101
|
end
|
102
|
+
|
103
|
+
ApiPagination::Railtie.initializers.each(&:run)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 5.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: actionpack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 5.0.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 5.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sequel
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/api-pagination.rb
|
91
91
|
- lib/api-pagination/configuration.rb
|
92
92
|
- lib/api-pagination/hooks.rb
|
93
|
+
- lib/api-pagination/railtie.rb
|
93
94
|
- lib/api-pagination/version.rb
|
94
95
|
- lib/grape/pagination.rb
|
95
96
|
- lib/rails/pagination.rb
|