Sha256: 6ba9953a48d953ba3520176084baea7a4ace5761bd901950101e3c9e623be38f

Contents?: true

Size: 802 Bytes

Versions: 4

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

module Micro
  class Case
    module Flow
      module ClassMethods
        def __flow__
          @__flow
        end

        def flow(*args)
          @__flow = flow_reducer.build(args)
        end

        def call(options = {})
          new(options).call
        end
      end

      CONSTRUCTOR = <<-RUBY
      def initialize(options)
        @options = options

        flow = self.class.__flow__

        raise Error::UndefinedFlow unless flow
      end
      RUBY

      private_constant :ClassMethods, :CONSTRUCTOR

      def self.included(base)
        def base.flow_reducer; Reducer; end

        base.extend(ClassMethods)

        base.class_eval(CONSTRUCTOR)
      end

      def call
        self.class.__flow__.call(@options)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
u-case-2.0.0 lib/micro/case/flow.rb
u-case-2.0.0.pre.4 lib/micro/case/flow.rb
u-case-2.0.0.pre.3 lib/micro/case/flow.rb
u-case-2.0.0.pre.2 lib/micro/case/flow.rb