Class: CPEE::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/cpee/callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, handler, method, event, key, protocol, *data) ⇒ Callback

Returns a new instance of Callback.



18
19
20
21
22
23
24
25
26
# File 'lib/cpee/callback.rb', line 18

def initialize(info,handler,method,event,key,protocol,*data)
  @info = info
  @event = event
  @key = key
  @data = data
  @handler = handler
  @protocol = protocol
  @method = method.class == Symbol ? method : :callback
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



28
29
30
# File 'lib/cpee/callback.rb', line 28

def info
  @info
end

#methodObject (readonly)

Returns the value of attribute method.



28
29
30
# File 'lib/cpee/callback.rb', line 28

def method
  @method
end

#protocolObject (readonly)

Returns the value of attribute protocol.



28
29
30
# File 'lib/cpee/callback.rb', line 28

def protocol
  @protocol
end

Instance Method Details

#callback(result = nil, options = nil) ⇒ Object



35
36
37
# File 'lib/cpee/callback.rb', line 35

def callback(result=nil,options=nil)
  @handler.send @method, result, options, *@data
end

#delete_if!(event, key) ⇒ Object



30
31
32
33
# File 'lib/cpee/callback.rb', line 30

def delete_if!(event,key)
  @handler.send @method, :DELETE, nil, *@data if @key == key && @event == event
  nil
end