Sha256: b213d774f102d3d1776c6bcdbe674727d4b8f1cbbf25b1984c5d3f717cd45ca6
Contents?: true
Size: 1.19 KB
Versions: 10
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true module ROM module Commands class Lazy # Lazy command wrapper for update commands # # @api public class Update < Lazy # Execute a lazy update command # # @see Commands::Update#call # # @return [Hash, Array<Hash>] # # @api public def call(*args) first = args.first last = args.last size = args.size if size > 1 && last.is_a?(Array) last.map.with_index do |parent, index| children = evaluator.call(first, index) children.map do |child| command_proc[command, parent, child].call(child, parent) end end.reduce(:concat) else input = evaluator.call(first) if input.is_a?(Array) input.map.with_index do |item, _index| command_proc[command, last, item].call(item, *args[1..size - 1]) end else command_proc[command, *(size > 1 ? [last, input] : [input])] .call(input, *args[1..size - 1]) end end end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems