Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add #page method in array #244

Closed
wants to merge 2 commits into from

2 participants

@shaynekang

Now we can use Array#page method like ActiveRecord or DataMapper.
Best regards.

paranoiase Kang added some commits
paranoiase Kang add #page method in Array 6e83c18
paranoiase Kang refactor spec fe9b4c5
@mislav
Owner

See #248

@mislav mislav closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 25, 2012
  1. add #page method in Array

    paranoiase Kang authored
  2. refactor spec

    paranoiase Kang authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +4 −0 lib/will_paginate/array.rb
  2. +11 −0 spec/finders/array_spec.rb
View
4 lib/will_paginate/array.rb
@@ -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
11 spec/finders/array_spec.rb
@@ -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
Something went wrong with that request. Please try again.