From 36249ae2ac86b3258c1482580836a82036e254ef Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 20 Sep 2014 12:54:47 -0700 Subject: Refactor notice selection and make it more foolproof for empty affects blocks. Signed-off-by: Robin H. Johnson --- lib/notice_store.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/notice_store.rb b/lib/notice_store.rb index 907c379..098c25e 100644 --- a/lib/notice_store.rb +++ b/lib/notice_store.rb @@ -56,15 +56,19 @@ class NoticeStore end end + def notice_affects_service(notice, service) + return (notice.has_key? 'affects' and not notice['affects'].nil? and notice['affects'].include? service) + end + def active_notices_for(service) active_notices.select do |notice| - notice.has_key? 'affects' and notice['affects'].include? service + notice_affects_service(notice, service) end end def visible_notices_for(service) visible_notices.select do |notice| - notice.has_key? 'affects' and notice['affects'].include? service + notice_affects_service(notice, service) end end -- cgit v1.2.3-65-gdbad