Module: EMRugged::Deferrable

Included in:
Repository
Defined in:
lib/em_rugged/deferrable.rb

Instance Method Summary collapse

Instance Method Details

#defer(method) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/em_rugged/deferrable.rb', line 30

def defer(method)
  define_method(method) do |*args|
    d = EM::DefaultDeferrable.new
    EM.defer do
      begin
        d.succeed(subject.send(method, *args))
      rescue Exception => err
        d.fail(err)
      end
    end
    d
  end
end