Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dgorodnichy/87f2b539ce98e0f6c226ef3263a03287 to your computer and use it in GitHub Desktop.
Save dgorodnichy/87f2b539ce98e0f6c226ef3263a03287 to your computer and use it in GitHub Desktop.
class NotifyPostAuthorAboutLikeActionScript
Result = Struct.new(:success?, :errors)
def initialize(post)
@post = post
end
def perform
notification = Notification.new(
user: @post.author,
message: "Your post <b>'#{@post.title.truncate(30)}'</b> was liked!"
)
if notification.save
Result.new(true, [])
else
Result.new(false, notification.errors)
end
rescue StandardError => e
Result.new(false, e.message)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment