def build_operation_chain(stack)
      empty_op = EmptyOperation.new(nil)

      stack.reverse.reduce(empty_op) do |next_op, current_op|
        klass, args, block = current_op

        if Class === klass
          klass.new(next_op, *args, &block)
        elsif Proc === klass
          lambda do |env|
            next_op.call(klass.call(env, *args))
          end
        else
          raise StandardError, "Invalid operation, doesn't respond to `call`: #{klass.inspect}"
        end
      end
    end
def build_operation_chain(stack)
      empty_op = EmptyOperation.new(nil)

      stack.reverse.reduce(empty_op) do |next_op, current_op|
        klass, args, block = current_op

        if Class === klass
          klass.new(next_op, *args, &block)
        elsif Proc === klass
          lambda do |env|
            next_op.call(klass.call(env, *args))
          end
        else
          raise StandardError, "Invalid operation, doesn't respond to `call`: #{klass.inspect}"
        end
      end
    end
Iterate through the stack and build a single
 callable object which consists of each operation
 referencing the next one in the chain