Module: Marconi::Broadcaster
- Defined in:
- lib/marconi/broadcaster.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #publish(operation) ⇒ Object
- #publish_create ⇒ Object
- #publish_destroy ⇒ Object
- #publish_update ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 10 |
# File 'lib/marconi/broadcaster.rb', line 7 def self.included(base) base.extend ClassMethods base.setup end |
Instance Method Details
#publish(operation) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/marconi/broadcaster.rb', line 39 def publish(operation) # This is set in Receiver if it's included. Intent is to # prevent sending messages in response to incoming messages and thus # creating infinite loops. return if self.class.respond_to?(:broadcasts_suppressed?) && self.class.broadcasts_suppressed? fmt = "%28s %9s %s Published" % [guid,operation,Time.now.to_s] logger.debug fmt Marconi.log(fmt) e = Envelope.new { |e| e.send(operation, self) } topic = "#{Marconi.application_name}.#{self.class.master_model_name}.#{operation}" exchange.publish(e.to_s, :topic => topic) end |
#publish_create ⇒ Object
31 32 33 |
# File 'lib/marconi/broadcaster.rb', line 31 def publish_create publish('create') end |
#publish_destroy ⇒ Object
35 36 37 |
# File 'lib/marconi/broadcaster.rb', line 35 def publish_destroy publish('destroy') end |
#publish_update ⇒ Object
27 28 29 |
# File 'lib/marconi/broadcaster.rb', line 27 def publish_update publish('update') end |