class OodCore::BatchConnect::Factory
A factory that builds a batch connect template object from a configuration.
Public Class Methods
build(config)
click to toggle source
Build a batch connect template from a configuration @param config [#to_h] configuration describing batch connect template @option config [#to_s] :template The batch connect template to use @raise [TemplateNotSpecified] if no template is specified @raise [TemplateNotFound] if the specified template does not exist @return [Template] the batch connect template object
# File lib/ood_core/batch_connect/factory.rb, line 17 def build(config) c = config.to_h.symbolize_keys template = c.fetch(:template) { raise TemplateNotSpecified, "batch connect configuration does not specify template" }.to_s path_to_template = "ood_core/batch_connect/templates/#{template}" begin require path_to_template rescue Gem::LoadError => e raise Gem::LoadError, "Specified '#{template}' for batch connect template, but the gem is not loaded." rescue LoadError => e raise LoadError, "Could not load '#{template}'. Make sure that that batch connect template in the configuration file is valid." end template_method = "build_#{template}" unless respond_to?(template_method) raise TemplateNotFound, "batch connect configuration specifies nonexistent #{template} template" end send(template_method, c) end
build_basic(config)
click to toggle source
Build the basic template from a configuration @param config [#to_h] the configuration for the batch connect template
# File lib/ood_core/batch_connect/templates/basic.rb, line 10 def self.build_basic(config) context = config.to_h.symbolize_keys.reject { |k, _| k == :template } Templates::Basic.new(context) end
build_vnc(config)
click to toggle source
Build the VNC template from a configuration @param config [#to_h] the configuration for the batch connect template
# File lib/ood_core/batch_connect/templates/vnc.rb, line 10 def self.build_vnc(config) context = config.to_h.symbolize_keys.reject { |k, _| k == :template } Templates::VNC.new(context) end