elocal_api_support 0.1.5 → 0.1.7

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: 455780104403fda2d28072b536aaaf848e4c2ef5
4
- data.tar.gz: 06467ae9ce02d600906deefb1911e6b932a6878f
3
+ metadata.gz: 647e718d434d57645ffe02fb1c31147e0f67cae6
4
+ data.tar.gz: f96f4d3d65aa353deb8b4361aef685f628de993d
5
5
  SHA512:
6
- metadata.gz: 2c148f0b6d4414b7aaf90ca08d7fd45f2911cebee78965a6f0d41ab30dfa007637849049b1e8ea91eceff4ed26f0750fc2c210ab5d1141e3c2e0ef3dfa7c0ba0
7
- data.tar.gz: 0aca16e0dda837efa4a372bb4c0ec9bf06b9dd417f59d3807bc8d39dd429dd262c0a2b5841708ffd53da23961754823d3ae2d6fc71d936f1efc4c3d9ad1b34ea
6
+ metadata.gz: ff18b48e210a10b526eabd67cb2a47690e4683dc562ff7d4ed7a42389d8a3f054c412681512d6313f28eb0e8bd82262f13efd1277f9d3bca7440e7cec15562fb
7
+ data.tar.gz: f21ca084f3a357b78f86317794f50aa8eceae46cbbcc967afe33c6d43368a14394088d54fc7682ca17804f479131835afe417baec715801370d95de95f356f6d
@@ -10,6 +10,10 @@ module ElocalApiSupport
10
10
 
11
11
  protected
12
12
 
13
+ def require_pagination?
14
+ true
15
+ end
16
+
13
17
  # Her library likes to paginate with headers,
14
18
  # ActiveResource cannot handle headers.
15
19
  # So awesomely, two implementations. To use the "Her" implementation with headers
@@ -50,7 +54,7 @@ module ElocalApiSupport
50
54
  end
51
55
 
52
56
  def paginated_request?
53
- params[:page].present? || params[:per_page].present?
57
+ require_pagination? || params[:page].present? || params[:per_page].present?
54
58
  end
55
59
  end
56
60
  end
@@ -16,7 +16,7 @@ module ElocalApiSupport::ModelFromParams
16
16
  end
17
17
 
18
18
  def with_pagination(rel)
19
- if params[:page] || params[:per_page]
19
+ if paginated_request?
20
20
  rel.page(current_page).per(per_page)
21
21
  else
22
22
  rel.page(current_page).limit(false)
@@ -56,8 +56,12 @@ module ElocalApiSupport::ModelFromParams
56
56
  rel
57
57
  end
58
58
 
59
+ def default_per_page
60
+ 500
61
+ end
62
+
59
63
  def per_page
60
- @per_page ||= (params[:per_page] || 10).to_i
64
+ @per_page ||= (params[:per_page] || default_per_page).to_i
61
65
  end
62
66
 
63
67
  def current_page
@@ -1,3 +1,3 @@
1
1
  module ElocalApiSupport
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elocal_api_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Di Marco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport