pragma 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pragma/operation/index.rb +32 -17
- data/lib/pragma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3525d4eab039669962cfcfadd4d2964793fd068c
|
4
|
+
data.tar.gz: 4a24b914c72a8b0eafc667c3b5ec574aee2548ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b8b05804dce0332f58b2a5e8ea33308d1f8bebd27f266c78d088919fa05fbdcec122405c8ee51c108e59b3fa2df0d1f56400896482e964552a2858fc3ff6d54
|
7
|
+
data.tar.gz: 3e8fb2c636469ebdaa92840250d50b4ff5a019ade2a2bc56cc1cd454c26e0b019071582397019c7d36f4d2402e9837041da27829ce163b2c56aeda269f06d4a9
|
@@ -39,26 +39,28 @@ module Pragma
|
|
39
39
|
self.class.model_klass.all
|
40
40
|
end
|
41
41
|
|
42
|
-
# Returns the
|
43
|
-
# parameter is not present.
|
42
|
+
# Returns the name of the page parameter.
|
44
43
|
#
|
45
|
-
# @return [
|
46
|
-
def
|
47
|
-
|
48
|
-
params[:page].to_i
|
44
|
+
# @return [Symbol]
|
45
|
+
def page_param
|
46
|
+
:page
|
49
47
|
end
|
50
48
|
|
51
|
-
# Returns the number
|
52
|
-
# parameter, up to a maximum of {#max_per_page} records, or {#default_per_page} if the
|
53
|
-
# parameter is not present.
|
49
|
+
# Returns the page number. By default, this is the page parameter or 1 if it is empty.
|
54
50
|
#
|
55
51
|
# @return [Fixnum]
|
56
52
|
#
|
57
|
-
# @see #
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
# @see #page_param
|
54
|
+
def page
|
55
|
+
return 1 if !params[page_param] || params[page_param].empty?
|
56
|
+
params[page_param].to_i
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns the name of the per_page param.
|
60
|
+
#
|
61
|
+
# @return [Symbol]
|
62
|
+
def per_page_param
|
63
|
+
:per_page
|
62
64
|
end
|
63
65
|
|
64
66
|
# Returns the default number of records per page.
|
@@ -75,14 +77,27 @@ module Pragma
|
|
75
77
|
100
|
76
78
|
end
|
77
79
|
|
80
|
+
# Returns the number of records to include per page. By default, this is the +per_page+
|
81
|
+
# parameter, up to a maximum of {#max_per_page} records, or {#default_per_page} if the
|
82
|
+
# parameter is not present.
|
83
|
+
#
|
84
|
+
# @return [Fixnum]
|
85
|
+
#
|
86
|
+
# @see #default_per_page
|
87
|
+
# @see #max_per_page
|
88
|
+
# @see #per_page_param
|
89
|
+
def per_page
|
90
|
+
return default_per_page if !params[per_page_param] || params[per_page_param].empty?
|
91
|
+
params[per_page_param].to_i > max_per_page ? max_per_page : params[per_page_param].to_i
|
92
|
+
end
|
93
|
+
|
78
94
|
# Builds the URL to a specific page in the collection.
|
79
95
|
#
|
80
96
|
# @param page [Fixnum] a page number
|
81
97
|
#
|
82
98
|
# @return [String]
|
83
|
-
def build_page_url(
|
84
|
-
|
85
|
-
context.page_url_builder.call(page)
|
99
|
+
def build_page_url(_page)
|
100
|
+
nil
|
86
101
|
end
|
87
102
|
end
|
88
103
|
end
|
data/lib/pragma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Desantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pragma-operation
|