Sha256: 80792563a3771754a0a25abcf788356d93520c631144efa2590e16ada06ef9f8

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

module Trailblazer
  class Finder
    module Activities
      class PrepareAdapter < Trailblazer::Activity::Railway
        def set_adapter(ctx, **)
          ctx[:adapter] = ctx.dig(:config, :adapter) || "Basic"
        end

        def validate_adapter(_ctx, adapter:, **)
          (ORM_ADAPTERS + ["Basic"]).include? adapter.to_s
        end

        def invalid?((ctx, _flow_options), **_circuit_options)
          (ctx[:errors] ||= []) << {adapter: "The specified adapter are invalid"}
        end

        step :set_adapter
        step :validate_adapter
        fail :invalid?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trailblazer-finder-0.90.0 lib/trailblazer/finder/activities/prepare_adapter.rb
trailblazer-finder-0.80.1 lib/trailblazer/finder/activities/prepare_adapter.rb
trailblazer-finder-0.70.0 lib/trailblazer/finder/activities/prepare_adapter.rb