From f9501577e485db4a71b27733338dd25f040a7eb2 Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Sun, 20 Sep 2015 15:48:26 +0200 Subject: [PATCH] improve code style --- lib/resources/service.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/resources/service.rb b/lib/resources/service.rb index 9feb02901..fa90d5853 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -314,8 +314,19 @@ class WindowsSrv < ServiceManager # check that we got a response return nil if service.nil? || service['Service'].nil? - (!service['Service'].nil? && !service['Service']['Status'].nil? && service['Service']['Status'] == 4) ? (running = true) : (running = false) - (!service['WMI'].nil? && !service['WMI']['StartMode'].nil? && service['WMI']['StartMode'] == 'Auto') ? (enabled = true) : (enabled = false) + # detect if service is running + if !service['Service']['Status'].nil? && service['Service']['Status'] == 4 + running = true + else + running = false + end + + # detect if service is enabled + if !service['WMI'].nil? && !service['WMI']['StartMode'].nil? && service['WMI']['StartMode'] == 'Auto' + enabled = true + else + enabled = false + end { name: service['Service']['Name'],