7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/walruz/more/pagination/base.rb', line 7
def authorized_paginate(actor, action, *args)
options = args.last if Hash === args.last
options[:page] ||= 1
options[:page] = options[:page].to_i
offset = options.delete(:offset).to_i
acum = []
while true
paginated_collection = self.paginate(*args)
filter_authorized_items_in_collection(actor, action, acum, paginated_collection, offset)
if complete_authorized_items_page?(acum, paginated_collection)
break
else
offset = 0
options[:page] += 1
end
end
paginated_collection.replace(acum)
end
|