diff options
author | 2014-09-20 12:54:47 -0700 | |
---|---|---|
committer | 2014-09-20 12:54:55 -0700 | |
commit | 36249ae2ac86b3258c1482580836a82036e254ef (patch) | |
tree | c0c0586d19739291e2f1a9eafa45bbe3bdfe2cee | |
parent | Update the example. (diff) | |
download | infra-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.rb | 8 |
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 |