9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/boss/pagination.rb', line 9
def self.included(base)
class_name = Pagination.get_class_name(base.name)
base.send :define_singleton_method, "#{class_name}_for_index", lambda { |options={}|
options.keys.map(&:to_sym)
options = { index_limit: Object.const_get(class_name.upcase.to_sym)["index_limit"]}.merge options
if options[:starts_at] && options[:starts_at] != 0
base.limit(options[:index_limit]).offset(options[:starts_at])
elsif options[:starts_at] && options[:starts_at] == 0
[]
else
base.limit(options[:index_limit])
end
}
end
|