summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@orbis-terrarum.net>2014-09-20 12:54:47 -0700
committerRobin H. Johnson <robbat2@orbis-terrarum.net>2014-09-20 12:54:55 -0700
commit36249ae2ac86b3258c1482580836a82036e254ef (patch)
treec0c0586d19739291e2f1a9eafa45bbe3bdfe2cee
parentUpdate the example. (diff)
downloadinfra-status-36249ae2ac86b3258c1482580836a82036e254ef.tar.gz
infra-status-36249ae2ac86b3258c1482580836a82036e254ef.tar.bz2
infra-status-36249ae2ac86b3258c1482580836a82036e254ef.zip
Refactor notice selection and make it more foolproof for empty affects blocks.
Signed-off-by: Robin H. Johnson <robbat2@orbis-terrarum.net>
-rw-r--r--lib/notice_store.rb8
1 files 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