Module: Filterable::Datable::After

Defined in:
lib/filterable/datable/after.rb

Overview

Keeps rows whose datable attribute is strictly after the bound. Reads filters[<attribute>][after].

Class Method Summary collapse

Class Method Details

.call(params, scope) ⇒ ActiveRecord::Relation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Narrows the scope to rows strictly after each declared attribute's after bound.

Parameters:

  • params (Hash, ActionController::Parameters)

    the nested filters params.

  • scope (ActiveRecord::Relation)

    the relation being filtered.

Returns:

  • (ActiveRecord::Relation)

    the narrowed relation.



16
17
18
19
20
21
22
23
# File 'lib/filterable/datable/after.rb', line 16

def call(params, scope)
  Filterable::Datable.columns(params, scope).reduce(scope) do |sub_scope, (column, bounds)|
    after = Filterable::Datable.parse(bounds[:after])
    next sub_scope unless after

    sub_scope.where(scope.arel_table[column].gt(after))
  end
end