Skip to content

Commit

Permalink
style: improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
owen2345 committed Apr 28, 2021
1 parent c608cdd commit bcf80c0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/pub_sub_model_sync/message_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def notify_error(error)
log("Error processing message: #{info}", :error) if res != :skip_log
end

# TODO: include payload.settings[:mode] when filtering
def filter_subscribers
config.subscribers.select do |subscriber|
subscriber.from_klass == payload.klass && subscriber.action == payload.action
Expand Down
2 changes: 1 addition & 1 deletion lib/pub_sub_model_sync/message_publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def end_transaction(parent_key)
# @return Payload
def publish_data(klass, data, action, headers: {})
attrs = { klass: klass.to_s, action: action.to_sym }
payload = PubSubModelSync::Payload.new(data, attrs, headers)
payload = PubSubModelSync::Payload.new(data, attrs.merge(mode: :klass), headers)
publish(payload)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pub_sub_model_sync/payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MissingInfo < StandardError; end
attr_reader :data, :settings, :headers

# @param data (Hash: { any value }):
# @param settings (Hash: { klass*: string, action*: :sym }):
# @param settings (Hash: { klass*: string, action*: :sym, mode?: :klass|:model }):
# @param headers (Hash):
# key (String): identifier of the payload, default:
# klass/action: when class message
Expand Down
6 changes: 0 additions & 6 deletions lib/pub_sub_model_sync/subscriber_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ def ps_class_subscribe(action, settings = {})
add_ps_subscriber(action, nil, settings)
end

def ps_subscriber(action = :create)
PubSubModelSync::Config.subscribers.find do |subscriber|
subscriber.klass == name && subscriber.action == action
end
end

private

# @param settings (Hash): refer to PubSubModelSync::Subscriber.settings
Expand Down

0 comments on commit bcf80c0

Please sign in to comment.