module ROM::Commands::Graph::ClassInterface
Class methods for command Graph
@api private
Public Instance Methods
build(registry, options, path = EMPTY_ARRAY)
click to toggle source
Build a command graph recursively
This is used by `Container#command` when array with options is passed in
@param [Registry] registry The command registry from container @param [Array] options The options array @param [Array] path The path for input evaluator proc
@return [Graph]
@api private
# File lib/rom/commands/graph/class_interface.rb, line 23 def build(registry, options, path = EMPTY_ARRAY) options.reduce { |spec, other| build_command(registry, spec, other, path) } end
build_command(registry, spec, other, path)
click to toggle source
@api private
# File lib/rom/commands/graph/class_interface.rb, line 28 def build_command(registry, spec, other, path) cmd_opts, nodes = other key, relation = if spec.is_a?(Hash) spec.to_a.first else [spec, spec] end name, opts = if cmd_opts.is_a?(Hash) cmd_opts.to_a.first else [cmd_opts] end command = registry[relation][name] tuple_path = Array[*path] << key input_proc = InputEvaluator.build(tuple_path, nodes) command = command.curry(input_proc, opts) if nodes if nodes.all? { |node| node.is_a?(Array) } command.combine(*nodes.map { |node| build(registry, node, tuple_path) }) else command.combine(build(registry, nodes, tuple_path)) end else command end end