Last active
October 2, 2020 03:01
-
-
Save renatodex/64ccfbf886a13bb1b054076eee911ad3 to your computer and use it in GitHub Desktop.
unpublish_movies.rb
This file contains 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 UnpublishMovies | |
def call | |
movies_to_unpublish = Movies.where_not( | |
unpublish_at: nil, | |
) | |
series_to_unpublish = Series.where_not( | |
unpublish_at: nil, | |
) | |
shows_to_unpublish = Shows.where_not( | |
unpublish_at: nil, | |
) | |
movies_to_unpublish.each do |movie| | |
if movie.unpublish_at <= Time.now | |
movie.unpublish_from_catalog! | |
end | |
end | |
series_to_unpublish.each do |serie| | |
if series.unpublish_at <= Time.now | |
series.unpublish_from_catalog! | |
end | |
end | |
shows_to_unpublish.each do |show| | |
if shows.unpublish_at <= Time.now | |
shows.unpublish_from_catalog! | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment