Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #page method in array #244

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/will_paginate/array.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ def paginate(options = {})
pager.replace self[pager.offset, pager.per_page].to_a pager.replace self[pager.offset, pager.per_page].to_a
end end
end end

def page(num)
paginate(:page => num)
end
end end
11 changes: 11 additions & 0 deletions spec/finders/array_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -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