Permalink
Browse files

Create default pubsub method node_event & node_item_event

  • Loading branch information...
Jack C Hong
Jack C Hong committed May 4, 2012
1 parent 844e868 commit 37da63068bdb0a14b3dc35944ef2cd4bc6e2bc47
View
@@ -1 +0,0 @@
-test
@@ -91,7 +91,11 @@ def publish(node, message, host, &block)
end
def node_event(*args, &block)
- pubsub_event(*args, &new_block(__method__, &block))
+ pubsub_event(:items, *args, &new_block(__method__, &block))
+ end
+
+ def node_item_event(*args, &block)
+ pubsub_event(:items, :node, *args, &new_block(__method__, &block))
end
private
View
@@ -65,7 +65,7 @@ comm.when_ready do
end
end
-comm.node_event :items, :node do |e|
+comm.node_item_event do |e|
e.items.each do |item|
m = OmfCommon::Message.parse(item.payload)
logger.error "Invalid Message\n#{m.to_xml}" unless m.valid?
@@ -109,7 +109,7 @@ def register_default_comm_callbacks
end
# Fired when message published
- @comm.node_event :items, :node do |e|
+ @comm.node_item_event do |e|
e.items.each do |item|
m = OmfCommon::Message.parse(item.payload)
logger.error "Invalid Message\n#{m.to_xml}" unless m.valid?
@@ -149,7 +149,7 @@ def register_default_comm_callbacks
end
# Fired when node created
- @comm.node_event :items do |e|
+ @comm.node_event do |e|
logger.info "NODES: #{e.items.map(&:id)}" unless e.items.empty?
end

0 comments on commit 37da630

Please sign in to comment.