Sha256: 8c4b6ff693497a3739be80c58f5559c7e2063f735907e34109302cad74964e65

Contents?: true

Size: 783 Bytes

Versions: 8

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

module Trailblazer
  class Finder
    module Activities
      class PrepareFilters < Trailblazer::Activity::Railway
        def validate_filters(ctx, **)
          filters = ctx.dig(:config, :filters)
          filters.each do |key, _value|
            return false if !filters[key][:with].nil? && !filters[key][:with].is_a?(Symbol)
          end
          true
        end

        def invalid_filters_error(ctx, **)
          (ctx[:errors] ||= []) << {filters: "One or more filters are missing a with method definition"}
        end

        def set_filters(ctx, **)
          ctx[:filters] = ctx[:config][:filters]
        end

        step :validate_filters
        fail :invalid_filters_error
        step :set_filters
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
trailblazer-finder-0.91.0 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.90.0 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.80.1 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.70.0 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.50.0 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.10.3 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.10.2 lib/trailblazer/finder/activities/prepare_filters.rb
trailblazer-finder-0.10.1 lib/trailblazer/finder/activities/prepare_filters.rb