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

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

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

Class Method Details

.build(registry, options, path = EMPTY_ARRAY) ⇒ Graph Originally defined in module ClassInterface

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.

Build a command graph recursively

This is used by Container#command when array with options is passed in

Parameters:

  • registry (Registry)

    The command registry from container

  • options (Array)

    The options array

  • path (Array) (defaults to: EMPTY_ARRAY)

    The path for input evaluator proc

Returns:

.build_command(registry, spec, other, path) ⇒ Object Originally defined in module ClassInterface

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.

Instance Method Details

#>>(other) ⇒ Relation::Composite Originally defined in module Pipeline::Operator

Compose two relation with a left-to-right composition

Examples:

users.by_name('Jane') >> tasks.for_users

Parameters:

  • other (Relation)

    The right relation

Returns:

#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

#map_with(*names) ⇒ Relation::Composite Originally defined in module Pipeline

Send data through specified mappers

Returns:

#respond_to_missing?(name, include_private = false) ⇒ Boolean Originally defined in module Pipeline::Proxy

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)