Module: Parse::Stack::Async

Defined in:
lib/parse/stack/async.rb,
lib/parse/stack/async/version.rb

Overview

This is a plugin to Parse Stack that allows objects to be saved and deleted in a background thread, while providing you a callback block.

Constant Summary collapse

VERSION =

Version number for this gem

"0.1.0"

Class Method Summary collapse

Class Method Details

.run(type = :parallel) ⇒ Object

Helper method to run a block on a background thread.

Parameters:

  • type (Symbol) (defaults to: :parallel)

    the queue to use when dispatching the block.

    • :serial - add the request to a serial queue.

    • :parallel - add the request to a concurrent queue.



44
45
46
47
48
49
50
51
# File 'lib/parse/stack/async.rb', line 44

def self.run(type = :parallel)
  raise "You need to pass a block to async." unless block_given?
  if type == :parallel
    ParallelDispatchQueue.perform_async Proc.new
  else
    SerialDispatchQueue.perform_async Proc.new
  end
end