Class: Trailblazer::Finder::Activities::Find

Inherits:
Activity::Railway
  • Object
show all
Defined in:
lib/trailblazer/finder/activities/find.rb

Constant Summary collapse

PREDICATES =
%w[eq not_eq blank not_blank lt lte gt gte sw not_sw ew not_ew cont not_cont].freeze

Instance Method Summary collapse

Instance Method Details

#process_params(ctx, params:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/trailblazer/finder/activities/find.rb', line 9

def process_params(ctx, params:, **)
  params.each do |attribute, value|
    result = {}
    filter_attribute = attribute.to_sym
    fetch_filters(ctx, result, filter_attribute) || result if ctx[:filters].include?(filter_attribute)
    fetch_properties(result, filter_attribute, value, ctx[:properties]) || result
    next ctx[:params].delete(attribute) if result.empty?

    ctx[:process] ||= {}
    ctx[:process][filter_attribute] = result.merge!(value: value)
  end
  true
end

#set_finder(ctx) ⇒ Object



23
24
25
# File 'lib/trailblazer/finder/activities/find.rb', line 23

def set_finder(ctx, **)
  ctx[:finder] = Finder::Find.new(ctx[:entity], ctx[:params], ctx[:process], ctx[:paging], ctx[:sorting], ctx[:config])
end