Class: Apache::Modules

Inherits:
Object
  • Object
show all
Defined in:
lib/apache/modules.rb

Overview

Create lists of modules to load in the Apache 2.2 style (with LoadModule only)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.modulesObject

Returns the value of attribute modules.



5
6
7
# File 'lib/apache/modules.rb', line 5

def modules
  @modules
end

Class Method Details

.build(*modules, &block) ⇒ Object

Build a block of LoadModule commands

Apache::Modules.build(:expires, :headers) do
  funky "/path/to/funky/module.so"
end

becomes:

LoadModule "expires_module" "modules/mod_expires.so"
LoadModule "headers_module" "modules/mod_headers.so"
LoadModule "funky_module" "/path/to/funky/module.so"


23
24
25
26
27
28
29
30
# File 'lib/apache/modules.rb', line 23

def build(*modules, &block)
  reset!

  modules.each { |mod| self.send(mod) }
  self.instance_eval(&block) if block

  [ '' ] + @modules + [ '' ]
end

.method_missing(method, *args) ⇒ Object

The method name becomes the module core name



33
34
35
36
37
# File 'lib/apache/modules.rb', line 33

def method_missing(method, *args)
  module_name = "#{method}_module"
  module_path = args[0] || "modules/mod_#{method}.so"
  @modules << [ 'LoadModule', *[ module_name, module_path ].quoteize ] * " "
end

.reset!Object

Reset the list of modules to output



8
9
10
# File 'lib/apache/modules.rb', line 8

def reset!
  @modules = []
end