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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 704792bfb16d43b1b651ec55de4fdd038d45946f
4
- data.tar.gz: 156f0365aa53d1a1dc3697a1299d1fc1575af8f6
3
+ metadata.gz: 3525d4eab039669962cfcfadd4d2964793fd068c
4
+ data.tar.gz: 4a24b914c72a8b0eafc667c3b5ec574aee2548ae
5
5
  SHA512:
6
- metadata.gz: 314aa4f9f7f4a155f3a0efe0391d51d691c5ad13afe5cfc1c2586039d32d31be0d9bfe9b22ec8cefbaf7f610e559403583203ff125dacb0dbaf9131ad76a5370
7
- data.tar.gz: 3a53239d2a00ff0b91a07d31ed267363033c84cda641fc68e5963512cab5b2a9cf4cbbbe840aeff20d5cb911e8714b0c3bcec57b9b7768856bbd060bf28cc10b
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 current page number. By default, this is the +page+ parameter or 1 if the
43
- # parameter is not present.
42
+ # Returns the name of the page parameter.
44
43
  #
45
- # @return [Fixnum]
46
- def page
47
- return 1 if !params[:page] || params[:page].empty?
48
- params[:page].to_i
44
+ # @return [Symbol]
45
+ def page_param
46
+ :page
49
47
  end
50
48
 
51
- # Returns the number of records to include per page. By default, this is the +per_page+
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 #default_per_page
58
- # @see #max_per_page
59
- def per_page
60
- return default_per_page if !params[:per_page] || params[:per_page].empty?
61
- params[:per_page].to_i > max_per_page ? max_per_page : params[:per_page].to_i
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(page)
84
- context.page_url_builder ||= ->(_page) { nil }
85
- context.page_url_builder.call(page)
99
+ def build_page_url(_page)
100
+ nil
86
101
  end
87
102
  end
88
103
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Pragma
3
- VERSION = '0.1.4'
3
+ VERSION = '0.2.0'
4
4
  end
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.1.4
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: 2016-12-31 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pragma-operation