Class: Concur::EventMachineFutureCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/futures/event_machine_future.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callbackable, &block) ⇒ EventMachineFutureCallback

Returns a new instance of EventMachineFutureCallback.



22
23
24
25
26
27
28
# File 'lib/futures/event_machine_future.rb', line 22

def initialize(callbackable, &block)
  puts 'EventMachineFutureCallback.initialize: ' + callbackable.inspect
  @callbackable = callbackable
  if block_given?
    @callblk = block
  end
end

Instance Attribute Details

#callblkObject

Returns the value of attribute callblk.



20
21
22
# File 'lib/futures/event_machine_future.rb', line 20

def callblk
  @callblk
end

#errblkObject

Returns the value of attribute errblk.



20
21
22
# File 'lib/futures/event_machine_future.rb', line 20

def errblk
  @errblk
end

Instance Method Details

#callback(&blk) ⇒ Object



51
52
53
# File 'lib/futures/event_machine_future.rb', line 51

def callback &blk
  @callblk = blk
end

#callback2(&blk) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/futures/event_machine_future.rb', line 66

def callback2 &blk
  puts 'EventMachineFutureCallback.callback'
  proc = Proc.new do
    @result = []
    if @callblk
      @result = @callblk.call(@callbackable)
    end
    blk.call(@result)
  end
  @callbackable.callback &proc
end

#errback(&blk) ⇒ Object



47
48
49
# File 'lib/futures/event_machine_future.rb', line 47

def errback &blk
  @errblk = blk
end

#errback2(&blk) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/futures/event_machine_future.rb', line 55

def errback2 &blk
  puts 'EventMachineFutureCallback.errback'
  proc = Proc.new do
    puts 'errback proc'
    blk.call(@callbackable)
  end
  puts 'setting errback on ' + @callbackable.inspect
  @callbackable.errback &proc
  puts 'errback set'
end

#future?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/futures/event_machine_future.rb', line 16

def future?
  true
end

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/futures/event_machine_future.rb', line 30

def run

#      http = @callbackable
#      http.errback {
#        @ex = EventMachineError.new(http)
#        complete
#      }
#      http.callback {
#        if @callback
#          @callback.call(@callbackable)
#        end
#        complete
#      }


end