Add #page method in array #244

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+15 −0
Diff settings

Always

Just for now

@@ -30,4 +30,8 @@ def paginate(options = {})
pager.replace self[pager.offset, pager.per_page].to_a
end
end
+
+ def page(num)
+ paginate(:page => num)
+ end
end
View
@@ -0,0 +1,11 @@
+require 'will_paginate/array'
+require 'spec_helper'
+
+describe Array do
+ subject { (1..99).to_a }
+
+ it "supports the page() method" do
+ subject.page(1).should == (1..30).to_a
+ subject.page(2).should == (31..60).to_a
+ end
+end