class Parse::Object

Additions to the Parse::Object class.

Public Instance Methods

delete_eventually()
Alias for: destroy_eventually
destroy_eventually() click to toggle source

Adds support for deleting a Parse object in the background. @example

object.destroy_eventually do |success|
   puts 'Deleted successfully' if success
end

@yield A block to call after the deletion has completed. @yieldparam [Boolean] success whether the save was successful.' @return [Boolean] whether the job was enqueued.

# File lib/parse/stack/async.rb, line 92
def destroy_eventually
  block = block_given? ? Proc.new : nil
  _self = self
  Parse::Stack::Async.run do
    begin
      result = true
      _self.destroy
    rescue => e
      result = false
      puts "[DestroyEventually] Failed for object #{_self.parse_class}##{_self.id}: #{e}"
    ensure
      block.call(result) if block
      block = nil
      _self = nil
    end # begin
  end # do
end
Also aliased as: delete_eventually
save_eventually() click to toggle source

Adds support for saving a Parse object in the background. @example

object.save_eventually do |success|
   puts "Saved successfully" if success
end

@yield A block to call after the save has completed. @yieldparam [Boolean] success whether the save was successful. @return [Boolean] whether the job was enqueued.

# File lib/parse/stack/async.rb, line 66
def save_eventually
  block = block_given? ? Proc.new : nil
  _self = self
  Parse::Stack::Async.run do
    begin
      result = true
      _self.save!
    rescue => e
      result = false
      puts "[SaveEventually] Failed for object #{_self.parse_class}##{_self.id}: #{e}"
    ensure
      block.call(result) if block
      block = nil
      _self = nil
    end # begin
  end # do
end