Class: MultipleMan::ModelPublisher
- Inherits:
-
Object
- Object
- MultipleMan::ModelPublisher
- Defined in:
- lib/multiple_man/model_publisher.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ModelPublisher
constructor
A new instance of ModelPublisher.
- #publish(records, operation = :create) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ModelPublisher
Returns a new instance of ModelPublisher.
6 7 8 |
# File 'lib/multiple_man/model_publisher.rb', line 6 def initialize( = {}) self. = .with_indifferent_access end |
Instance Method Details
#publish(records, operation = :create) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/multiple_man/model_publisher.rb', line 10 def publish(records, operation=:create) return unless MultipleMan.configuration.enabled Connection.connect do |connection| ActiveSupport::Notifications.instrument('multiple_man.publish_messages') do all_records(records) do |record| ActiveSupport::Notifications.instrument('multiple_man.publish_message') do push_record(connection, record, operation) end end end end rescue Exception => ex MultipleMan.error(ex) end |