Skip to content

Instantly share code, notes, and snippets.

@renatodex
Last active October 2, 2020 03:01
Show Gist options
  • Save renatodex/64ccfbf886a13bb1b054076eee911ad3 to your computer and use it in GitHub Desktop.
Save renatodex/64ccfbf886a13bb1b054076eee911ad3 to your computer and use it in GitHub Desktop.
unpublish_movies.rb
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