Created
October 2, 2020 02:41
-
-
Save renatodex/78eac31ba7291782e9e13c76e4fc86a9 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 UnpublishMovies | |
def call | |
to_unpublish_list = [ | |
{ | |
field: :unpublish_at, | |
klasses: [Movies, Series, Shows], | |
}, | |
{ | |
field: :date_to_unpublish_podcast, | |
klasses: [Podcast], | |
} | |
] | |
to_unpublish_list.each do |list| | |
list[:klasses].each do |klass| | |
items_to_unpublish = klass.where( | |
"#{list[:field]}" => nil, | |
) | |
items_to_unpublish.each(&: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