lib/isono/node_modules/job_worker.rb
# Run the block/proc. This is simple utility method for start().
#
# @param [Proc,nil] run_cb
# @param [Proc,nil] fail_cb
#
# @example Run 
#  run {
#    puts "message"
#  }
# @example Use proc{} for setting both run and fail block.
#  run(proc{
#        # do something
#      }, proc{
#        # do rollback on fail
#      })
Run the block/proc. This is simple utility method for start().
Run the block / proc . This is simple utility method for start () .
def run(run_cb=nil, fail_cb=nil, &blk)
        if run_cb.is_a?(Proc)
          start do |job|
            job.run_cb = run_cb
            job.fail_cb = fail_cb if fail_cb.is_a?(Proc)
          end
        elsif blk
          start do |job|
            job.run_cb = blk
          end
        end
      end
def run ( run_cb = nil , fail_cb = nil , & blk ) if run_cb . is_a? ( Proc ) start do | job | job . run_cb = run_cb job . fail_cb = fail_cb if fail_cb . is_a? ( Proc ) end elsif blk start do | job | job . run_cb = blk end end end
Run the block/proc.
Run the block / proc .
run_cb
fail_cb
blk
None
example
Run run { puts "message" }
Run run { puts " message " }
example
Use proc{} for setting both run and fail block. run(proc{ # do something }, proc{ # do rollback on fail })
Use proc {} for setting both run and fail block . run ( proc { # do something } proc { # do rollback on fail } )