lib/redstream/model.rb in redstream-0.2.0 vs lib/redstream/model.rb in redstream-0.3.0

- old
+ new

@@ -35,25 +35,17 @@ after_touch { |object| instance_variable_set(IVAR_DELAY_MESSAGE_ID, producer.delay(object)) } after_destroy { |object| instance_variable_set(IVAR_DELAY_MESSAGE_ID, producer.delay(object)) } after_commit(on: [:create, :update]) do |object| if object.saved_changes.present? - producer.queue(object) - - if id = instance_variable_get(IVAR_DELAY_MESSAGE_ID) - producer.delete(object, id) - remove_instance_variable(IVAR_DELAY_MESSAGE_ID) - end + producer.queue(object, delay_message_id: instance_variable_get(IVAR_DELAY_MESSAGE_ID)) + instance_variable_set(IVAR_DELAY_MESSAGE_ID, nil) end end after_commit(on: :destroy) do |object| - producer.queue(object) - - if id = instance_variable_get(IVAR_DELAY_MESSAGE_ID) - producer.delete(object, id) - remove_instance_variable(IVAR_DELAY_MESSAGE_ID) - end + producer.queue(object, delay_message_id: instance_variable_get(IVAR_DELAY_MESSAGE_ID)) + instance_variable_set(IVAR_DELAY_MESSAGE_ID, nil) end end def redstream_name name.pluralize.underscore