trouble with this case statement Ruby -
can me understand how write case statement not working , noob have no idea how fix it:
def hide_link?(link, mailing) case link when 'edit' && ['sent', 'sending', 'archived'].include?(mailing.status) return true when 'send_schedule' && ['sent', 'sending', 'archived'].include?(mailing.status) return true when 'archive' && ['archived'].include?(mailing.status) puts "i should in here" return true else 'dashboard' && ['sending', 'draft'].include?(mailing.status) return true end end
basically want return true when link matches criteria.
i believe if link doesn't match these criterias method should return false. thus:
def hide_link?(link, mailing) case link when 'edit' ['sent', 'sending', 'archived'].include?(mailing.status) when 'send_schedule' ['sent', 'sending', 'archived'].include?(mailing.status) when 'archive' puts "i should in here" ['archived'].include?(mailing.status) when 'dashboard' ['sending', 'draft'].include?(mailing.status) else false end end
the construction [...].include?(mailing.status)
has result true
or false
returned result of hide_link?
method.
Comments
Post a Comment