Class: ROM::Commands::Composite

Inherits:
Pipeline::Composite
  • Object
show all
Defined in:
core/lib/rom/commands/composite.rb

Overview

Composite command that consists of left and right commands

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROM::Pipeline::Proxy

Instance Method Details

#call(*args) ⇒ Object Also known as: []

Calls the composite command

Right command is called with a result from the left one

Returns:

  • (Object)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'core/lib/rom/commands/composite.rb', line 18

def call(*args)
  response = left.call(*args)

  if response.nil? || (many? && response.empty?)
    return one? ? nil : EMPTY_ARRAY
  end

  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