From e6f6324ebea9fc46d5d617a08c2eb239349d9f90 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 7 Aug 2015 18:08:14 -0700 Subject: move 'enabled service' calculation to a macro. --- provider_base/lib/macros/provider.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 provider_base/lib/macros/provider.rb (limited to 'provider_base/lib/macros/provider.rb') diff --git a/provider_base/lib/macros/provider.rb b/provider_base/lib/macros/provider.rb new file mode 100644 index 00000000..84c4e1b8 --- /dev/null +++ b/provider_base/lib/macros/provider.rb @@ -0,0 +1,20 @@ +# +# These macros are intended only for use in provider.json, although they are +# currently loaded in all .json contexts. +# + +module LeapCli + module Macro + + # + # returns an array of the service names, including only those services that + # are enabled for this environment. + # + def enabled_services + manager.env(self.environment).services[:service_type => :user_service].field(:name).select { |service| + manager.nodes[:environment => self.environment][:services => service].any? + } + end + + end +end -- cgit v1.2.3