Sha256: 71c784bbd25a2fd7f33b3c52f6a98e1b7b3be4eb191ca1a79c768c47e1cbe910

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

module Trailblazer
  class Finder
    module Activity
      module Prepare
        # Prepare Entity Activity
        module Entity
          extend Trailblazer::Activity::Railway()

          module_function

          def validate_entity(ctx, **)
            ctx[:options][:entity] || ctx[:config][:entity]
          end

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

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

          step method(:validate_entity), id: :validate_entity
          fail method(:invalid_entity_error), id: :invalid_entity_error
          step method(:set_entity), id: :set_entity
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trailblazer-finder-0.3.0 lib/trailblazer/finder/activity/prepare/entity.rb
trailblazer-finder-0.2.7 lib/trailblazer/finder/activity/prepare/entity.rb
trailblazer-finder-0.2.6 lib/trailblazer/finder/activity/prepare/entity.rb
trailblazer-finder-0.2.5 lib/trailblazer/finder/activity/prepare/entity.rb