Skip to content

Instantly share code, notes, and snippets.

@xionon
Created June 23, 2014 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xionon/748fe3f148ef3f37daec to your computer and use it in GitHub Desktop.
Save xionon/748fe3f148ef3f37daec to your computer and use it in GitHub Desktop.
# Ensures that we can save a news item and queue up the right jobs around it
class NewsSaveService
def self.save!(news)
new(news).save!
end
def initialize(news)
@news = news
end
def save!
@news.class.transaction do
@news.save!
queue_send_to_listserv_job
queue_future_cache_expiration_job
end
end
end
@xionon
Copy link
Author

xionon commented Jun 23, 2014

Usage:

news = News.find(params[:id])
NewsSaveService.save!( news )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment