Module: Trinidad::Extensions

Defined in:
lib/trinidad/extensions.rb

Defined Under Namespace

Classes: Extension, OptionsExtension, ServerExtension, WebAppExtension

Class Method Summary collapse

Class Method Details

.configure_options_extensions(extensions, parser, default_options) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/trinidad/extensions.rb', line 25

def self.configure_options_extensions(extensions, parser, default_options)
  if extensions
    extensions.each do |name, options|
      if extension = extension(name, 'OptionsExtension', options)
        extension.configure(parser, default_options)
      end
    end
  end
end

.configure_server_extensions(extensions, tomcat) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/trinidad/extensions.rb', line 13

def self.configure_server_extensions(extensions, tomcat)
  if extensions
    extensions.each do |name, options|
      if extension = extension(name, 'ServerExtension', options)
        configured_tomcat = extension.configure(tomcat)
        tomcat = configured_tomcat if extension.override_tomcat?
      end
    end
  end
  tomcat
end

.configure_webapp_extensions(extensions, tomcat, app_context) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/trinidad/extensions.rb', line 3

def self.configure_webapp_extensions(extensions, tomcat, app_context)
  if extensions
    extensions.each do |name, options|
      if extension = extension(name, 'WebAppExtension', options)
        extension.configure(tomcat, app_context)
      end
    end
  end
end

.extension(name, type, options) ⇒ Object



35
36
37
38
39
40
# File 'lib/trinidad/extensions.rb', line 35

def self.extension(name, type, options)
  class_name = (camelize(name.to_s) << type).to_sym
  load_extension(name) unless const_defined?(class_name)
  clazz = const_get(class_name) rescue nil
  clazz.new(options) if clazz
end

.load_extension(name) ⇒ Object



42
43
44
# File 'lib/trinidad/extensions.rb', line 42

def self.load_extension(name)
  require "trinidad_#{name}_extension"
end