module
Avram::AfterCommitCallback
Included Modules
Direct including types
Defined in:
avram/callbacks/after_commit_callback.crMacro Summary
-
after_commit(method_name, if _if = nil, unless _unless = nil)
Run the given method after save and after successful transaction commit
-
after_commit(if _if = nil, unless _unless = nil, &block)
Run the given block after save and after successful transaction commit
Macros inherited from module Avram::CallbackHelpers
conditional_error_for_block_callbacks(callback, condition)
conditional_error_for_block_callbacks
Macro Detail
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
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