Sha256: 3d7c7f1d8c89b1f6e08f0b9945341c59320705a75d3e0c764d726ebf0f7edbb8

Contents?: true

Size: 1021 Bytes

Versions: 5

Compression:

Stored size: 1021 Bytes

Contents

module ROM
  module Commands
    # Composite command that consists of left and right commands
    #
    # @api public
    class Composite < Pipeline::Composite
      # Calls the composite command
      #
      # Right command is called with a result from the left one
      #
      # @return [Object]
      #
      # @api public
      def call(*args)
        response = left.call(*args)

        if one? && !graph?
          if right.is_a?(Command) || right.is_a?(Commands::Composite)
            right.call([response].first)
          else
            right.call([response]).first
          end
        elsif one? && graph?
          right.call(response).first
        else
          right.call(response)
        end
      end
      alias_method :[], :call

      # @api private
      def graph?
        left.is_a?(Graph)
      end

      # @api private
      def result
        left.result
      end

      # @api private
      def decorate?(response)
        super || response.is_a?(Graph)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rom-0.9.0 lib/rom/commands/composite.rb
rom-0.9.0.rc1 lib/rom/commands/composite.rb
rom-0.9.0.beta1 lib/rom/commands/composite.rb
rom-0.8.1 lib/rom/commands/composite.rb
rom-0.8.0 lib/rom/commands/composite.rb