Class: RubyHaze::Topic

Inherits:
Object
  • Object
show all
Includes:
Mixins::DOProxy
Defined in:
lib/rubyhaze/topic.rb

Instance Attribute Summary

Attributes included from Mixins::DOProxy

#name

Attributes included from Mixins::Proxy

#proxy_object

Instance Method Summary collapse

Methods included from Mixins::DOProxy

included

Methods included from Mixins::NativeException

#rescue_native_exception

Methods included from Mixins::Compare

#==

Methods included from Mixins::Proxy

included, #method_missing, #respond_to?

Constructor Details

#initialize(name) ⇒ Topic

Returns a new instance of Topic.



9
10
11
12
# File 'lib/rubyhaze/topic.rb', line 9

def initialize(name)
  @name = name.to_s
  @proxy_object = Hazelcast.get_topic @name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RubyHaze::Mixins::Proxy

Instance Method Details

#on_message(&blk) ⇒ Object



14
15
16
17
18
19
# File 'lib/rubyhaze/topic.rb', line 14

def on_message(&blk)
  klass = Class.new
  klass.send :include, MessageListener
  klass.send :define_method, :on_message, &blk
  proxy_object.add_message_listener klass.new
end