napa_pagination 0.0.4 → 0.0.5

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: deb862f59da8ed1c1df3e7d7d8c8823b00109da8
4
- data.tar.gz: f9698f0a91dad8b045dd850e1f8c4e8e07adb5dd
3
+ metadata.gz: 47472e768bcf0125009c3d9a9ae75b7a94836c8a
4
+ data.tar.gz: 85cc7d5b4416b46e8c933f486ce8569dfdf02a99
5
5
  SHA512:
6
- metadata.gz: ae48eadddde8de0784b530f1c3fe2bb445d912b87413065592a26335fc47e9808c39fc1b5ccf0332ff158361a2e2d10842166f83711b309598303d4aa4fa0a6d
7
- data.tar.gz: 94735c539549b6402268d27784d41f0793a36fad2f29592167f1fc789f996eab63e4f4acb0432fae868650beb88f36378e3bd145fe79aa4b74a7bb061777de31
6
+ metadata.gz: e6781a322f0126db727bc4ceed4a30c209718a26ffff251c6063ed9eae8c342399e20b848b9bd520752347006ec2621e790df38681fd2d25206343c53f0bfa6b
7
+ data.tar.gz: e3b05a5aaa9f1777d7395d6f1d3bf2dd0e841b3890aec1309300aff488e5410754670d22eef46622309ebbfedb70489ec93699735714c04838042c164792177c
@@ -21,7 +21,7 @@ module NapaPagination
21
21
  page = params.try(:page) || 1
22
22
  per_page = params.try(:per_page) || 25
23
23
 
24
- order_by_params!(data) if data.is_a?(ActiveRecord::Relation) && data.size > 0
24
+ order_by_params!(data) if data.is_a?(ActiveRecord::Relation) && data.size > 0
25
25
 
26
26
  if data.is_a?(Array)
27
27
  Kaminari.paginate_array(data).page(page).per(per_page)
@@ -31,14 +31,16 @@ module NapaPagination
31
31
  end
32
32
 
33
33
  def order_by_params!(data)
34
- if data.column_names.map(&:to_sym).include?(params[:sort_by])
34
+ if params[:sort_by] && data.column_names.map(&:to_sym).include?(params[:sort_by].to_sym)
35
35
  sort_order = params.try(:sort_order) || :asc
36
- data.order!(params[:sort_by] => sort_order)
36
+ data.order!(params[:sort_by] => sort_order.to_sym)
37
37
  end
38
38
  data
39
39
  end
40
40
 
41
41
  # extend all endpoints to include this
42
- Grape::Endpoint.send :include, self
42
+ Grape::Endpoint.send :include, self if defined?(Grape)
43
+ # rails 4 controller concern
44
+ extend ActiveSupport::Concern if defined?(Rails)
43
45
  end
44
46
  end
@@ -1,3 +1,3 @@
1
1
  module NapaPagination
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napa_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darby Frey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  requirements: []
221
221
  rubyforge_project:
222
- rubygems_version: 2.0.7
222
+ rubygems_version: 2.1.11
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: A simple pagination representer for Napa