class Ant::Configuration::ServiceManager
Allow to autoload configurations into ruby. It allows to implement new plugins.
Attributes
configs[R]
Public Class Methods
auto_load!()
click to toggle source
# File lib/ant/configs/service_manager.rb, line 58 def self.auto_load! configs = Ant::Configuration::ConfigurationManager.auto_load! services = new(configs) services.configure! services end
new(configs, plugin_subdir = '.')
click to toggle source
# File lib/ant/configs/service_manager.rb, line 15 def initialize(configs, plugin_subdir = '.') @configs = configs @services = {} @plugin_subdir = plugin_subdir end
register_plugin(name, type = 'multi')
click to toggle source
The type unique is for global configurations as multi is for a hash containing all the objects to be created
# File lib/ant/configs/service_manager.rb, line 67 def self.register_plugin(name, type = 'multi') register(:plugins, name, type) end
Public Instance Methods
all_services()
click to toggle source
# File lib/ant/configs/service_manager.rb, line 25 def all_services @services end
build_service(name, config)
click to toggle source
# File lib/ant/configs/service_manager.rb, line 54 def build_service(name, config) Ant::Configuration::Autoconfigs.from_config!(name, config, @plugin_subdir) end
configure!()
click to toggle source
# File lib/ant/configs/service_manager.rb, line 29 def configure! plugins = self.class.resources(:plugins) plugins.each do |plug, type| next if @configs[plug].nil? case type when 'unique' @services[plug] = Ant::Configuration::Autoconfigs.from_config!(plug, @configs[plug]) else load_service!(plug, @configs[plug]) end end end
features()
click to toggle source
# File lib/ant/configs/service_manager.rb, line 71 def features @services['features'] end
load_service!(name, keys)
click to toggle source
# File lib/ant/configs/service_manager.rb, line 43 def load_service!(name, keys) return if keys&.empty? services = {} keys.each do |service, config| services[service] = build_service(name, config) end @services[name] = services end
services(cathegory, name)
click to toggle source
# File lib/ant/configs/service_manager.rb, line 21 def services(cathegory, name) @services[cathegory][name].raw end