Class: Qpid::Proton::Event::EventType

Inherits:
Object
  • Object
show all
Defined in:
lib/event/event_type.rb

Overview

Manages the association between an Event and the method which should process on the context object associated with an occurance of the event.

Each type is identified by a unique #type value.

Examples:


# SCENARIO: A part of an application handles extracting and decrypting
#            data received from a remote endpoint.
#
#            An EventType is created to notify handlers that such a
#            situation has occurred.

ENCRYPTED_RECV = 10000 # the unique constant value for the event

# create a new event type which, when it occurs, invokes a method
# named :on_encrypted_data when a handler is notified of its occurrance
Qpid::Proton::Event::ENCRYPTED_RECV =
  Qpid::Proton::Event::EventType.new(ENCRYPTED_RECV, :on_encrypted_data)

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, method) ⇒ EventType

Returns a new instance of EventType.



51
52
53
54
55
56
57
# File 'lib/event/event_type.rb', line 51

def initialize(number, method)
  @number = number
  @name = Cproton.pn_event_type_name(@number)
  @method = method
  @@types ||= {}
  @@types[number] = self
end

Instance Attribute Details

#methodObject (readonly)

The method to invoke on any potential handler.



48
49
50
# File 'lib/event/event_type.rb', line 48

def method
  @method
end

#numberObject (readonly)

Returns the value of attribute number.



49
50
51
# File 'lib/event/event_type.rb', line 49

def number
  @number
end