public
Fork of mislav/will_paginate
Description: Most awesome pagination solution for Rails
Homepage: http://github.com/mislav/will_paginate/wikis
Clone URL: git://github.com/technoweenie/will_paginate.git
move Array#paginate definition to will_paginate/array.rb
mislav (author)
Thu Apr 03 20:49:43 -0700 2008
commit  4c51c38bbf7f4f697e4f48b875127619d8b36947
tree    bc77c255eaae76db42b89f969701be7427a1683d
parent  903950020764618d01c72d624aa78867ed397ae8
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
20
21
22
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
5
0
@@ -1,22 +1,5 @@
0
 require 'set'
0
-require 'will_paginate/collection'
0
-
0
-unless Array.instance_methods.include? 'paginate'
0
- # http://www.desimcadam.com/archives/8
0
- Array.class_eval do
0
- def paginate(options = {})
0
- raise ArgumentError, "parameter hash expected (got #{options.inspect})" unless Hash === options
0
-
0
- WillPaginate::Collection.create(
0
- options[:page] || 1,
0
- options[:per_page] || 30,
0
- options[:total_entries] || self.length
0
- ) { |pager|
0
- pager.replace self[pager.offset, pager.per_page].to_a
0
- }
0
- end
0
- end
0
-end
0
+require 'will_paginate/array'
0
 
0
 unless Hash.instance_methods.include? 'except'
0
   Hash.class_eval do
...
1
2
 
3
4
5
...
11
12
13
14
 
 
15
16
17
...
1
 
2
3
4
5
...
11
12
13
 
14
15
16
17
18
0
@@ -1,5 +1,5 @@
0
 require File.dirname(__FILE__) + '/helper'
0
-require 'will_paginate/core_ext'
0
+require 'will_paginate/array'
0
 
0
 class ArrayPaginationTest < Test::Unit::TestCase
0
   def test_simple
0
@@ -11,7 +11,8 @@ class ArrayPaginationTest < Test::Unit::TestCase
0
      { :page => 3, :per_page => 5, :expected => [] },
0
     ].
0
     each do |conditions|
0
- assert_equal conditions[:expected], collection.paginate(conditions.slice(:page, :per_page))
0
+ expected = conditions.delete :expected
0
+ assert_equal expected, collection.paginate(conditions)
0
     end
0
   end
0
 

Comments

    No one has commented yet.