Skip to content
This repository
Browse code

enable use of Sequel datasets with `page_entries_info` helper

  • Loading branch information...
commit 3a3e07c729f0058f5de9fa64b27d21e303bcb865 1 parent 3a246ba
Mislav Marohnić authored August 04, 2011
5  lib/will_paginate/sequel.rb
@@ -13,6 +13,11 @@ def per_page
13 13
       page_size
14 14
     end
15 15
 
  16
+    def size
  17
+      current_page_record_count
  18
+    end
  19
+    alias length size
  20
+
16 21
     def total_entries
17 22
       pagination_record_count
18 23
     end
2  spec/console
@@ -3,6 +3,8 @@ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
3 3
 opts = %w[ --simple-prompt -rirb/completion ]
4 4
 if ARGV.include? '-dm'
5 5
   opts << '-rwill_paginate/data_mapper' << '-rfinders/data_mapper_test_connector'
  6
+elsif ARGV.include? '-seq'
  7
+  opts << '-rwill_paginate/sequel' << '-rfinders/sequel_test_connector'
6 8
 else
7 9
   opts << '-rconsole_fixtures'
8 10
 end
8  spec/finders/sequel_spec.rb
@@ -33,6 +33,9 @@ class Car < Sequel::Model
33 33
     it "should imitate WillPaginate::Collection" do
34 34
       result = Car.paginate(1, 2)
35 35
       
  36
+      result.should_not be_empty
  37
+      result.size.should == 2
  38
+      result.length.should == 2
36 39
       result.total_entries.should == 3
37 40
       result.total_pages.should == 2
38 41
       result.per_page.should == 2
@@ -42,6 +45,11 @@ class Car < Sequel::Model
42 45
     it "should perform" do
43 46
       Car.paginate(1, 2).all.should == [Car[1], Car[2]]
44 47
     end
  48
+
  49
+    it "should be empty" do
  50
+      result = Car.paginate(3, 2)
  51
+      result.should be_empty
  52
+    end
45 53
     
46 54
     it "should perform with #select and #order" do
47 55
       result = Car.select("name as foo".lit).order(:name).paginate(1, 2).all

0 notes on commit 3a3e07c

Please sign in to comment.
Something went wrong with that request. Please try again.