Sha256: c99509643872e7477c20c9ccdbb96a22f172905c93aaad5111025a761cf6da36

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

module Trailblazer
  class Finder
    module Activities
      class PrepareEntity < Trailblazer::Activity::Railway
        def validate_entity(ctx, **)
          ctx.dig(:options,:entity) || ctx.dig(:config,:entity)
        end

        def invalid_entity_error(ctx, **)
          (ctx[:errors] ||= []) << {entity: "Invalid entity specified"}
        end

        def set_entity(ctx, **)
          ctx[:entity] = ctx.dig(:options,:entity) || instance_eval(&ctx[:config][:entity])
        end

        step (:validate_entity)
        fail (:invalid_entity_error)
        step (:set_entity)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trailblazer-finder-0.10.2 lib/trailblazer/finder/activities/prepare_entity.rb
trailblazer-finder-0.10.1 lib/trailblazer/finder/activities/prepare_entity.rb