Class: ROM::Commands::Composite

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

Overview

Composite command that consists of left and right commands

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from ROM::Pipeline::Composite

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 '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

#decorate?(response) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


50
51
52
# File 'lib/rom/commands/composite.rb', line 50

def decorate?(response)
  super || response.is_a?(Graph)
end

#graph?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


40
41
42
# File 'lib/rom/commands/composite.rb', line 40

def graph?
  left.is_a?(Graph)
end

#resultObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/rom/commands/composite.rb', line 45

def result
  left.result
end