Sha256: 8c4fadd895c8b2eea0a68d22c6529b0ab31089235e680bdf0a781ae3bcba5389

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 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
        Success = Activity::Railway::End::Success
        Failure = Activity::Railway::End::Failure
      end
    end # Railway
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
trailblazer-operation-0.6.3 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.6.2 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.6.1 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.6.0 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.5.3 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.5.2 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.5.1 lib/trailblazer/operation/railway.rb
trailblazer-operation-0.5.0 lib/trailblazer/operation/railway.rb