Class: ROM::Commands::Graph Private

Inherits:
Object
  • Object
show all
Extended by:
ClassInterface, Initializer
Includes:
Pipeline, Pipeline::Proxy
Defined in:
lib/rom/commands/graph.rb,
lib/rom/commands/graph/class_interface.rb,
lib/rom/commands/graph/input_evaluator.rb

Overview

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

Command graph

Defined Under Namespace

Modules: ClassInterface Classes: InputEvaluator

Instance Method Summary collapse

Methods included from Initializer

extended

Methods included from ClassInterface

build, build_command

Methods included from Pipeline::Proxy

#respond_to_missing?

Methods included from Pipeline

#map_with

Methods included from Pipeline::Operator

#>>

Dynamic Method Handling

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

Instance Method Details

#call(*args) ⇒ Array

Calls root and all nodes with the result from root

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

Examples:

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

Returns:

  • (Array)

    nested array with command results



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rom/commands/graph.rb', line 50

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?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)


76
77
78
# File 'lib/rom/commands/graph.rb', line 76

def graph?
  true
end