Class: OmfRc::DeferredProcess

Inherits:
Object
  • Object
show all
Includes:
EM::Deferrable
Defined in:
omf_rc/lib/omf_rc/deferred_process.rb

Overview

To be used for handling long running processes

Instance Method Summary collapse

Instance Method Details

#fire(&block) ⇒ Object

Pass a block of long running process

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
24
# File 'omf_rc/lib/omf_rc/deferred_process.rb', line 13

def fire(&block)
  raise ArgumentError, "Missing code block to be executed" if block.nil?

  EM.defer do
    begin
      result = block.call
      succeed result
    rescue => e
      fail e
    end
  end
end