Module: Messaging::Handle::Info

Extended by:
Info
Included in:
Info
Defined in:
lib/messaging/handle.rb

Instance Method Summary collapse

Instance Method Details

#handler(message_or_message_data) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/messaging/handle.rb', line 88

def handler(message_or_message_data)
  handler_method_name = handler_method_name(message_or_message_data)

  if method_defined?(handler_method_name)
    return handler_method_name
  else
    return nil
  end
end

#handler_method_name(message_or_message_data) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/messaging/handle.rb', line 102

def handler_method_name(message_or_message_data)
  name = nil

  if message_or_message_data.is_a? MessageStore::MessageData::Read
    name = Messaging::Message::Info.canonize_name(message_or_message_data.type)
  elsif message_or_message_data.is_a? String
    name = Messaging::Message::Info.canonize_name(message_or_message_data)
  else
    name = message_or_message_data.message_name
  end

  "handle_#{name}".to_sym
end

#handles?(message_or_message_data) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/messaging/handle.rb', line 98

def handles?(message_or_message_data)
  method_defined? handler_method_name(message_or_message_data)
end