Module: Aws::Broker::Publishing
- Defined in:
- lib/aws/broker/publishing.rb
Instance Method Summary collapse
-
#publish_event(*events) ⇒ Object
only :create, :update, :destroy.
- #publish_topic ⇒ Object
-
#publish_topic=(topic) ⇒ Object
optional override of default topic.
Instance Method Details
#publish_event(*events) ⇒ Object
only :create, :update, :destroy
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aws/broker/publishing.rb', line 6 def publish_event(*events) events.each do |event| event = event.to_sym unless [:create, :update, :destroy].include?(event) raise "Invalid publish event #{event}" end method_name = :"publish_event_#{event}" define_method method_name do Broker.publish( self.class.publish_topic, event: event, id: id ) end after_commit method_name, on: event end end |
#publish_topic ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/aws/broker/publishing.rb', line 24 def publish_topic if defined?(@@publish_topic) @@publish_topic else to_s.underscore.tr('/', '_') end end |
#publish_topic=(topic) ⇒ Object
optional override of default topic
33 34 35 |
# File 'lib/aws/broker/publishing.rb', line 33 def publish_topic=(topic) @@publish_topic = topic end |