Last active
August 26, 2016 18:15
-
-
Save calebhearth/fcdc769068e3e8882755352cd60a61da 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 EmptyQueue | |
def initialize(company) | |
@company = company | |
end | |
def reasons | |
[ | |
{ | |
no_accounts: -> { company.accounts.none? }, | |
no_approved_content: -> { company.approved_contents.none? }, | |
}, | |
{ | |
no_contents_with_accounts: -> { company.contents_with_accounts.none? }, | |
}, | |
{ | |
no_categories: -> { company.categories.none? }, | |
no_timeslots: -> { company.schedules.none? }, | |
}, | |
{ | |
no_scheduled_content_accounts: -> { company.scheduled_content_accounts.none? }, | |
no_scheduled_content_categories: -> { company.scheduled_content_categories.none? }, | |
}, | |
{ | |
all_content_use_once_and_used: -> { company.used_all_use_once_content? }, | |
}, | |
].lazy. | |
map { |level_reasons| level_reasons.select { |k,v| v.call }.keys }. | |
detect(&:any?) || [] | |
end | |
private | |
attr_reader :company | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment