rename Relation#shift to padding

bacause this method name was turned out to be stubbing out Array#shift
This commit is contained in:
Akira Matsuda 2011-12-02 23:53:06 +09:00
parent aee027c91b
commit e79bad5b46
3 changed files with 8 additions and 8 deletions

View File

@ -63,11 +63,11 @@ Then bundle:
User.page(7).per(50)
Note that the +per+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you will never actually use +per_page+ without specifying the +page+ number.
* the +shift+ scope
* the +padding+ scope
Occasionally you need to shift a number of records that is not a multiple of the page size.
User.page(7).per(50).shift(3)
Note that the +shift+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you can use +offset+ otherwise.
Occasionally you need to padding a number of records that is not a multiple of the page size.
User.page(7).per(50).padding(3)
Note that the +padding+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you can use +offset+ otherwise.
=== General configuration options

View File

@ -12,7 +12,7 @@ module Kaminari
end
end
def shift(num)
def padding(num)
offset(offset_value + num.to_i)
end

View File

@ -58,9 +58,9 @@ describe Kaminari::ActiveRecordExtension do
end
end
describe '#shift' do
context 'page 1 per 5 shift 1' do
subject { model_class.page(1).per(5).shift(1) }
describe '#padding' do
context 'page 1 per 5 padding 1' do
subject { model_class.page(1).per(5).padding(1) }
it { should have(5).users }
its('first.name') { should == 'user002' }
end