Sha256: 2e0d44742e50f97a826207608dd5b982bd2e131dfff8a6427031ce65430b3f52

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

module Trailblazer
  # Operations is simply a thin API to define, inherit and run circuits by passing the options object.
  # It encourages the linear railway style (http://trb.to/gems/workflow/circuit.html#operation) but can
  # easily be extend for more complex workflows.
  class Operation
    # End event: All subclasses of End:::Success are interpreted as "success".
    module Railway
      # @param options Context
      # @param end_event The last emitted signal in a circuit is usually the end event.
      def self.Result(end_event, options, *)
        Result.new(end_event.kind_of?(End::Success), options, end_event)
      end

      # The Railway::Result knows about its binary state, the context (data), and the last event in the circuit.
      class Result < Result # Operation::Result
        def initialize(success, data, event)
          super(success, data)

          @event = event
        end

        attr_reader :event
      end

      module End
        class Success < Activity::End; end
        class Failure < Activity::End; end
      end

    end # Railway
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trailblazer-operation-0.4.1 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.4.0 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.3.1 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.3.0 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.5 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.4 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.3 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.2 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.1 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.2.0 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.1.3 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.1.2 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.1.1 lib/trailblazer/operation/railway.rb