14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/cylons/remote_pagination.rb', line 14
def search(params = {})
search_options = params.(*SEARCH_OPTION_KEYS)
search_options.delete_if {|k,v| v.nil? }
query_scope = params.inject(all) do |query, hash_pair|
query.__send__("by_#{hash_pair[0]}", hash_pair[1]).all
end.all
if search_options.present?
query_scope.paginate(:page => search_options[:options][:page], :per_page => search_options[:options][:per_page])
else
query_scope.paginate(:page => 1, :per_page => MAX_PER_PAGE)
end
end
|