Module: Wampus::Pubsub::ServerExt::ClassMethods
- Defined in:
- lib/wampus/pubsub/server_ext.rb
Instance Method Summary collapse
-
#register_topic(base_uri, allow_partial_uri_match = false) ⇒ Object
– Topic Handler Registration.
- #register_topic_handler(handler, base_uri = '', allow_partial_uri_match = false) ⇒ Object
- #register_topic_publish_block(uri, allow_partial_uri_match = false, &block) ⇒ Object
- #register_topic_publish_method(uri, handler, handler_method, allow_partial_uri_match = false) ⇒ Object
- #register_topic_subscribe_block(uri, allow_partial_uri_match = false, &block) ⇒ Object
- #register_topic_subscribe_method(uri, handler, handler_method, allow_partial_uri_match = false) ⇒ Object
Instance Method Details
#register_topic(base_uri, allow_partial_uri_match = false) ⇒ Object
– Topic Handler Registration
21 22 23 24 25 |
# File 'lib/wampus/pubsub/server_ext.rb', line 21 def register_topic(base_uri, allow_partial_uri_match = false) after_init do topics[base_uri] = Wampus::Topic.new(base_uri, allow_partial_uri_match) end end |
#register_topic_handler(handler, base_uri = '', allow_partial_uri_match = false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wampus/pubsub/server_ext.rb', line 27 def register_topic_handler(handler, base_uri = '', allow_partial_uri_match = false) after_init do handler.subscribe_handlers.each do |uri_or_fragment, handler_method| uri = base_uri + uri_or_fragment register_topic_subscribe_method uri, handler, handler_method, allow_partial_uri_match end handler.publish_handlers.each do |uri_or_fragment, handler_method| uri = base_uri + uri_or_fragment register_topic_publish_method uri, handler, handler_method, allow_partial_uri_match end end end |
#register_topic_publish_block(uri, allow_partial_uri_match = false, &block) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/wampus/pubsub/server_ext.rb', line 62 def register_topic_publish_block(uri, allow_partial_uri_match = false, &block) after_init do topic = topics[uri] ||= register_topic(uri, allow_partial_uri_match) topic.publish_handler = [nil, block, allow_partial_uri_match] end end |
#register_topic_publish_method(uri, handler, handler_method, allow_partial_uri_match = false) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/wampus/pubsub/server_ext.rb', line 48 def register_topic_publish_method(uri, handler, handler_method, allow_partial_uri_match = false) after_init do topic = topics[uri] ||= register_topic(uri, allow_partial_uri_match) topic.publish_handler = [handler, handler_method, allow_partial_uri_match] end end |
#register_topic_subscribe_block(uri, allow_partial_uri_match = false, &block) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/wampus/pubsub/server_ext.rb', line 55 def register_topic_subscribe_block(uri, allow_partial_uri_match = false, &block) after_init do topic = topics[uri] ||= register_topic(uri, allow_partial_uri_match) topic.subscribe_handler = [nil, block, allow_partial_uri_match] end end |
#register_topic_subscribe_method(uri, handler, handler_method, allow_partial_uri_match = false) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/wampus/pubsub/server_ext.rb', line 41 def register_topic_subscribe_method(uri, handler, handler_method, allow_partial_uri_match = false) after_init do topic = topics[uri] ||= register_topic(uri, allow_partial_uri_match) topic.subscribe_handler = [handler, handler_method, allow_partial_uri_match] end end |