Class: Yaqb::QueryBuilders::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/yaqb/query_builders/filter.rb

Constant Summary collapse

PREDICATES =
%w[eq cont notcont start end gt lt].freeze

Instance Method Summary collapse

Constructor Details

#initialize(scope, params, presenter) ⇒ Filter

Returns a new instance of Filter.



8
9
10
11
12
# File 'lib/yaqb/query_builders/filter.rb', line 8

def initialize(scope, params, presenter)
  @scope = scope
  @filters = params['q'] || {}
  @presenter = presenter
end

Instance Method Details

#filterObject



14
15
16
17
18
19
20
21
22
# File 'lib/yaqb/query_builders/filter.rb', line 14

def filter
  return @scope unless @filters.any?

  @filters = format_filters
  validate_filters
  build_filter_scope

  @scope
end