Created
March 17, 2015 00:35
-
-
Save HansHauge/c288ddddb35892c0f97c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UpdateRssFeedsJob < ActiveJob::Base | |
attr_accessor :r_jokes_feed | |
queue_as :default | |
def perform | |
update_r_jokes | |
end | |
def update_r_jokes | |
if r_jokes_feed | |
r_jokes_feed = Feedjira::Feed.update(r_jokes_feed) | |
Joke.update_from_feed(r_jokes_feed.new_entries) if r_jokes_feed.updated? | |
else | |
r_jokes_feed = Feedjira::Feed.fetch_and_parse('http://www.reddit.com/r/jokes/.rss') | |
Joke.update_from_feed(r_jokes_feed.entries) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment