rs_paginator 0.0.1 → 0.1.0

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: 1b34b9cb6e1afe9900b9c2fd7883a28aa4c32b9a
4
- data.tar.gz: a9f885f767f4723a8ceb6e37ce9b746b239008a7
3
+ metadata.gz: 8c60e98b08e5852369d82db4e55a0b041e9781dd
4
+ data.tar.gz: f8b9cb23a087642991f8fbfeb56d118e4e7b506a
5
5
  SHA512:
6
- metadata.gz: 0f8036b077a6f4734133789f9a4331e23161f18929d6cbc98bacc7fec85b19e49d3f3f911f1ff68681385e19f16e0d15b67078f3db5ba6b89ac06963859ab4cd
7
- data.tar.gz: 5169f67e267b1dff36ac771094e89981c2bca20c98533b1a51d895d5f0e5f17ef294170e231d7116487d9212b85f1caabdaf715302308ccbcfcadaa6a04129a7
6
+ metadata.gz: 47b065800eb2635985ea072796636b96a221ddbe17f0e75bc9bd7d96d7b28ee1240cce2a4f413ea8283774b93231a0fd7d84a546556e81fa24129558d304c29a
7
+ data.tar.gz: ac4d63040b64c937ee645341175cc21d86104ea1f733c1b07da02e74a313bc6146c8a481f153e53e7f7df0a039110d40df9b005bbde564896c0d643ed1e5a0c4
@@ -5,11 +5,12 @@ module RsPaginator
5
5
  include ActionView::Helpers::TagHelper
6
6
  include ActionView::Helpers::OutputSafetyHelper
7
7
 
8
- def initialize(objects, context)
8
+ def initialize(objects, context, extra_params: {})
9
9
  @objects = objects
10
10
  @context = context
11
11
  @total_pages = objects.total_pages
12
12
  @current_page = objects.page
13
+ @extra_params = extra_params
13
14
  end
14
15
 
15
16
  def render
@@ -20,10 +21,14 @@ module RsPaginator
20
21
 
21
22
  private
22
23
 
24
+ def params(h = {})
25
+ @context.params.merge(@extra_params).merge(h)
26
+ end
27
+
23
28
  def prev_link
24
29
  first = @current_page == 1
25
30
  content_tag(:li, class: first ? 'disabled' : nil) do
26
- url = first ? '#' : @context.params.merge(page: @current_page - 1)
31
+ url = first ? '#' : params(page: @current_page - 1)
27
32
  @context.link_to(raw('«'), url)
28
33
  end
29
34
  end
@@ -31,7 +36,7 @@ module RsPaginator
31
36
  def next_link
32
37
  last = @current_page == @total_pages
33
38
  content_tag(:li, class: last ? 'disabled' : nil) do
34
- url = last ? '#' : @context.params.merge(page: @current_page + 1)
39
+ url = last ? '#' : params(page: @current_page + 1)
35
40
  @context.link_to(raw('»'), url)
36
41
  end
37
42
  end
@@ -43,7 +48,7 @@ module RsPaginator
43
48
  def page_link(i)
44
49
  current = i == @current_page
45
50
  content_tag(:li, class: current ? 'active' : nil) do
46
- url = current ? '#' : @context.params.merge(page: i)
51
+ url = current ? '#' : params(page: i)
47
52
  @context.link_to(i, url)
48
53
  end
49
54
  end
@@ -1,5 +1,5 @@
1
1
  module RsPaginator
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
 
5
5
  end
@@ -1,8 +1,8 @@
1
1
  module RsPaginator
2
2
  module ViewHelpers
3
3
 
4
- def paginate(objects)
5
- RsPaginator::Paginator.new(objects, self).render
4
+ def paginate(objects, extra_params: {})
5
+ RsPaginator::Paginator.new(objects, self, extra_params: extra_params).render
6
6
  end
7
7
 
8
8
  def page_info(objects)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rs_paginator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Weiss <sebastian.weiss@radarservices.com
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-10 00:00:00.000000000 Z
12
+ date: 2014-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n