Module: Messaging::Message::Info

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.canonize_name(name) ⇒ Object



54
55
56
# File 'lib/messaging/message.rb', line 54

def self.canonize_name(name)
  name.gsub(/([^\^])([A-Z])/,'\1_\2').downcase
end

.class_name(message) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/messaging/message.rb', line 58

def self.class_name(message)
  class_name = nil
  class_name = message if message.instance_of? String
  class_name ||= message.name if message.instance_of? Class
  class_name ||= message.class.name
  class_name
end

Instance Method Details

#message_name(msg = self) ⇒ Object



50
51
52
# File 'lib/messaging/message.rb', line 50

def message_name(msg=self)
  Info.canonize_name(message_type(msg))
end

#message_type(msg = self) ⇒ Object



42
43
44
# File 'lib/messaging/message.rb', line 42

def message_type(msg=self)
  Info.class_name(msg).split('::').last
end

#message_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/messaging/message.rb', line 46

def message_type?(type)
  message_type == type
end