Module: WithScopedQueries::Limit

Defined in:
app/models/concerns/with_scoped_queries/limit.rb

Class Method Summary collapse

Class Method Details

.add_queriable_attributes_to(klass, _) ⇒ Object



11
12
13
# File 'app/models/concerns/with_scoped_queries/limit.rb', line 11

def self.add_queriable_attributes_to(klass, _)
  klass.queriable_attributes.merge!(limit: :limit)
end

.query_by(params, current_scope, _) ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/models/concerns/with_scoped_queries/limit.rb', line 2

def self.query_by(params, current_scope, _)
  if params[:limit].present?
    max_limit = [params[:limit].to_i, 25].min
    current_scope.limit(max_limit)
  else
    current_scope
  end
end