class Trailblazer::Finder::Activities::Find
Constants
- PREDICATES
Public Instance Methods
process_params(ctx, params:, **)
click to toggle source
# File lib/trailblazer/finder/activities/find.rb, line 10 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, **)
click to toggle source
# File lib/trailblazer/finder/activities/find.rb, line 24 def set_finder(ctx, **) ctx[:finder] = Finder::Find.new(ctx[:entity], ctx[:params], ctx[:process], ctx[:paging], ctx[:sorting], ctx[:config]) end
Private Instance Methods
fetch_filters(ctx, result, attribute)
click to toggle source
# File lib/trailblazer/finder/activities/find.rb, line 34 def fetch_filters(ctx, result, attribute) filter_attribute = ctx[:filters][attribute] result[:filter] = {} result[:name] = attribute result[:filter][:handler] = filter_attribute[:with] || filter_attribute[:block] end
fetch_properties(result, attribute, value, properties)
click to toggle source
# File lib/trailblazer/finder/activities/find.rb, line 41 def fetch_properties(result, attribute, value, properties) splitter = Utils::Splitter.new attribute, value PREDICATES.each do |predicate| next unless splitter.split_key predicate next unless properties.include?(splitter.field.to_sym) result[:name] = splitter.field result[:predicate] = predicate end end