Sha256: bab2850e4ef87a797171363554ddecba8724b5b9cdbac1611312a51879ef455f

Contents?: true

Size: 992 Bytes

Versions: 3

Compression:

Stored size: 992 Bytes

Contents

# Magic!
module BusinessFlow
  # More magic!
  # call! to raise errors
  # Hooks for cross cutting concerns
  # Figure out how much we can freeze
  module Base
    def self.included(klass)
      klass.include(DSL)
      klass.prepend(InstanceMethods)
    end

    # "Helper" methods which we put on an object to provide some default
    # behavior.
    module InstanceMethods
      attr_reader :parameter_object
      private :parameter_object

      def initialize(parameter_object)
        @parameter_object = parameter_object
        catch(:halt_step) do
          super()
        end
      end

      def call
        # If our initialization process set any errors, return
        return if errors.any? || invalid?
        if defined?(super)
          catch(:halt_step) do
            super
          end
        else
          ::BusinessFlow::DefaultStepExecutor.new(self.class.step_queue, self)
                                             .call
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
business_flow-0.4.2 lib/business_flow/base.rb
business_flow-0.4.1 lib/business_flow/base.rb
business_flow-0.4.0 lib/business_flow/base.rb