mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Merge branch 'patch-1' of https://github.com/samdalton/kaminari into samdalton-patch-1
Conflicts: lib/kaminari/models/array_extension.rb
This commit is contained in:
commit
807a2fa3e7
1 changed files with 4 additions and 4 deletions
|
@ -5,8 +5,8 @@ module Kaminari
|
|||
|
||||
attr_internal_accessor :limit_value, :offset_value
|
||||
|
||||
def initialize(original_array, limit_val = default_per_page, offset_val = 0) #:nodoc:
|
||||
@_original_array, @_limit_value, @_offset_value = original_array, limit_val.to_i, offset_val.to_i
|
||||
def initialize(original_array, limit_val = default_per_page, offset_val = 0, count = nil) #:nodoc:
|
||||
@_original_array, @_limit_value, @_offset_value, @_total_count = original_array, limit_val.to_i, offset_val.to_i, count
|
||||
super(original_array[offset_val, limit_val] || [])
|
||||
end
|
||||
|
||||
|
@ -22,12 +22,12 @@ module Kaminari
|
|||
|
||||
# total item numbers of the original array
|
||||
def total_count
|
||||
@_original_array.count
|
||||
@_total_count || @_original_array.count
|
||||
end
|
||||
|
||||
# returns another chunk of the original array
|
||||
def offset(num)
|
||||
arr = self.class.new @_original_array, limit_value, num
|
||||
arr = self.class.new @_original_array, limit_value, num, total_count
|
||||
class << arr
|
||||
include Kaminari::PageScopeMethods
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue