Sha256: e37093d71e19d63f3586573df984fd29f70e1835cd6b03d52bb9e0c451777c5a

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

require 'business_pipeline/config'
require 'business_pipeline/context'
require 'business_pipeline/hooks'

module BusinessPipeline
  module Step
    def self.included(base)
      base.class_eval do
        include Hooks

        attr_reader :context
        private :context

        attr_reader :config
        private :config

        def self.inherited(child_class)
          child_class.instance_variable_set(:@hooks, hooks)
        end
      end
    end

    def initialize(config = {})
      @config = BusinessPipeline::Config.new(config)
    end

    def call
      fail NotImplementedError
    end

    def fail!(additional_context = {})
      context.fail!(additional_context)
    end

    def perform(context = {})
      @context = BusinessPipeline::Context.build(context)
      with_hooks { call }
      @context
    end

    def succeed!(additional_context = {})
      context.succeed!(additional_context)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
business_pipeline-0.1.2 lib/business_pipeline/step.rb
business_pipeline-0.1.1 lib/business_pipeline/step.rb
business_pipeline-0.1.0 lib/business_pipeline/step.rb