Class: OmfCommon::Comm::Local::Topic

Inherits:
Topic
  • Object
show all
Defined in:
omf_common/lib/omf_common/comm/local/local_topic.rb

Constant Summary

@@marshall_messages =
true

Instance Attribute Summary

Attributes inherited from Topic

#id, #routing_key

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Topic

[], #add_message_handler, #after, #configure, #create, create, #create_message_and_publish, #error?, #inform, #initialize, #on_incoming_message, #on_inform, #on_message, #publish, #release, #request, #unsubscribe

Constructor Details

This class inherits a constructor from OmfCommon::Comm::Topic

Class Method Details

+ (Object) marshall_messages=(flag)

If set to 'true' marshall and immediately unmarshall before handing it on messages



16
17
18
# File 'omf_common/lib/omf_common/comm/local/local_topic.rb', line 16

def self.marshall_messages=(flag)
  @@marshall_messages = (flag == true)
end

Instance Method Details

- (Object) _send_message(msg, block = nil) (private)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'omf_common/lib/omf_common/comm/local/local_topic.rb', line 42

def _send_message(msg, block = nil)
  super
  debug "(#{id}) Send message #{msg.inspect}"
  if @@marshall_messages
    content_type, payload = msg.marshall(self)
    Message.parse(payload, content_type) do
      OmfCommon.eventloop.after(0) do
        on_incoming_message(msg)
      end
    end
  else
    OmfCommon.eventloop.after(0) do
      on_incoming_message(msg)
    end
  end
end

- (Object) address



28
29
30
# File 'omf_common/lib/omf_common/comm/local/local_topic.rb', line 28

def address
  @id
end

- (Object) on_subscribed(&block)



32
33
34
35
36
37
38
# File 'omf_common/lib/omf_common/comm/local/local_topic.rb', line 32

def on_subscribed(&block)
  return unless block

  OmfCommon.eventloop.after(0) do
    block.arity == 1 ? block.call(self) : block.call
  end
end

- (Object) to_s

end



24
25
26
# File 'omf_common/lib/omf_common/comm/local/local_topic.rb', line 24

def to_s
  "Local::Topic<#{id}>"
end