module

Avram::AfterCommitCallback

Inherits Avram::CallbackHelpers

Macros

after_commit(method_name, if _if = nil, unless _unless = nil)

Run the given method after save and after successful transaction commit

Optionally you can pass an if or unless argument which allows you to run this conditionally. The symbol should reference a method you've defined that returns a truthy/falsey value

The newly saved record will be passed to the method.

class SaveComment < Comment::SaveOperation
  after_commit notify_post_author

  private def notify_post_author(comment : Comment)
    NewCommentNotificationEmail.new(comment, to: comment.author!).deliver_now
  end
end
Source
after_commit(if _if = nil, unless _unless = nil, &block)

Run the given block after save and after successful transaction commit

The newly saved record will be passed to the method.

class SaveComment < Comment::SaveOperation
  after_commit do |comment|
    NewCommentNotificationEmail.new(comment, to: comment.author!).deliver_now
  end
end
Source