lib/graphiti/resource/persistence.rb
def around_callback_proc(callbacks, index, *args, &blk)
        method_name = callbacks[index][:callback]

        if callbacks[index + 1]
          proc do
            r = nil
            args = args[0..0] if method(method_name).arity == 1
            send(method_name, *args) do |r2|
              wrapped = around_callback_proc(callbacks, index + 1, r2, &blk)
              r = instance_exec(r2, &wrapped)
            end
            r
          end
        else
          proc do |*args2|
            r = nil
            args2 = args2[0..0] if method(callbacks[index][:callback]).arity == 1
            send(callbacks[index][:callback], *args2) do |r2|
              r = instance_exec(r2, &blk)
            end
            r
          end
        end
      end
# The tricky thing here is we need to yield to the next around callback
# until there are no more callbacks, then we want to call the original block
# Also keep in mind each callback needs to yield to the next
The tricky thing here is we need to yield to the next around callback
until there are no more callbacks, then we want to call the original block
Also keep in mind each callback needs to yield to the next
The tricky thing here is we need to yield to the next around callback until there are no more callbacks then we want to call the original block Also keep in mind each callback needs to yield to the next
def around_callback_proc(callbacks, index, *args, &blk)
        method_name = callbacks[index][:callback]
        if callbacks[index + 1]
          proc do
            r = nil
            args = args[0..0] if method(method_name).arity == 1
            send(method_name, *args) do |r2|
              wrapped = around_callback_proc(callbacks, index + 1, r2, &blk)
              r = instance_exec(r2, &wrapped)
            end
            r
          end
        else
          proc do |*args2|
            r = nil
            args2 = args2[0..0] if method(callbacks[index][:callback]).arity == 1
            send(callbacks[index][:callback], *args2) do |r2|
              r = instance_exec(r2, &blk)
            end
            r
          end
        end
      end
def around_callback_proc ( callbacks , index , * args , & blk ) method_name = callbacks [ index ] [ :callback ] if callbacks [ index + 1 ] proc do r = nil args = args [ 0 .. 0 ] if method ( method_name ) . arity == 1 send ( method_name , * args ) do | r2 | wrapped = around_callback_proc ( callbacks , index + 1 , r2 , & blk ) r = instance_exec ( r2 , & wrapped ) end r end else proc do | * args2 | r = nil args2 = args2 [ 0 .. 0 ] if method ( callbacks [ index ] [ :callback ] ) . arity == 1 send ( callbacks [ index ] [ :callback ] , * args2 ) do | r2 | r = instance_exec ( r2 , & blk ) end r end end end
The tricky thing here is we need to yield to the next around callback
until there are no more callbacks, then we want to call the original block
Also keep in mind each callback needs to yield to the next
The tricky thing here is we need to yield to the next around callback until there are no more callbacks then we want to call the original block Also keep in mind each callback needs to yield to the next
callbacks
index
args
blk