class ROM::Commands::Graph

Command graph

@api private

Public Instance Methods

call(*args) click to toggle source

Calls root and all nodes with the result from root

Graph results are mappable through `combine` operation in mapper DSL

@example

create_user = rom.commands[:users].create
create_task = rom.commands[:tasks].create

command = create_user
  .curry(name: 'Jane')
  .combine(create_task.curry(title: 'Task'))

command.call

@return [Array] nested array with command results

@api public

# File lib/rom/commands/graph.rb, line 52
def call(*args)
  left = root.call(*args)

  right = nodes.map { |node|
    response =
      if node.lazy?
        node.call(args.first, left)
      else
        node.call(left)
      end

    if node.one? && !node.graph?
      [response]
    else
      response
    end
  }

  if one?
    [[left], right]
  else
    [left, right]
  end
end
graph?() click to toggle source

@api private

# File lib/rom/commands/graph.rb, line 78
def graph?
  true
end

Private Instance Methods

composite_class() click to toggle source

@api public

# File lib/rom/commands/graph.rb, line 85
def composite_class
  Command::Composite
end