Skip to content

Commit 1c207a4

Browse files
committed
Check if create, update or noop event before publishing
1 parent fbb7baa commit 1c207a4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

README.routemaster_client.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ require 'roo_on_rails/routemaster/publisher'
5757
class BasePublisher < RooOnRails::Routemaster::Publisher
5858
include Rails.application.routes.url_helpers
5959

60-
def publish?
61-
noop? || model.new_record? || model.previous_changes.any?
62-
end
60+
# Add your method overrides here if needed
6361
end
6462
```
6563

lib/roo_on_rails/default.env

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RACK_WAIT_TIMEOUT=30
1818
ROOBUS_URL=''
1919
ROOBUS_UUID=''
2020
ROUTEMASTER_ENABLED=false
21+
ROUTEMASTER_PUBLISHING_ENABLED=false
2122
SIDEKIQ_ENABLED=true
2223
SIDEKIQ_THREADS=25
2324
SIDEKIQ_DATABASE_REAPING_FREQUENCY=10

lib/roo_on_rails/routemaster/publisher.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(model, event, client: ::Routemaster::Client)
1313
end
1414

1515
def publish?
16-
true
16+
noop? || @model.new_record? || @model.previous_changes.any?
1717
end
1818

1919
def will_publish?
@@ -22,7 +22,7 @@ def will_publish?
2222

2323
def publish!
2424
return unless will_publish?
25-
@client.send(event, topic, url, data: stringify_keys(data))
25+
@client.send(@event, topic, url, data: stringify_keys(data))
2626
end
2727

2828
def topic
@@ -39,7 +39,7 @@ def data
3939

4040
%i(created updated deleted noop).each do |event_type|
4141
define_method :"#{event_type}?" do
42-
event.to_sym == event_type
42+
@event.to_sym == event_type
4343
end
4444
end
4545

0 commit comments

Comments
 (0)