Sha256: bf3da102606b93d50da37a43ba6862071337e36620f5ab1f6a910fd666289971

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

module Flows
  class Flow
    class Router
      # Router with static paths for successful and failure results.
      class Simple < Router
        # @param success_route [Symbol] route for any successful results.
        # @param failure_route [Symbol] route for any failure results.
        def initialize(success_route, failure_route)
          @success_route = success_route
          @failure_route = failure_route
        end

        # @see Flows::Flow::Router#call
        def call(result)
          result.ok? ? @success_route : @failure_route
        end

        # @see Flows::Flow::Router#destinations
        def destinations
          [@success_route, @failure_route]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flows-0.6.0 lib/flows/flow/router/simple.rb
flows-0.5.1 lib/flows/flow/router/simple.rb
flows-0.5.0 lib/flows/flow/router/simple.rb