Class: Webgen::Configuration

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/webgen/configuration.rb

Overview

Stores the configuration for a webgen website.

Configuration options should be created like this:

config.my.new.config 'value', :doc => 'some', :meta => 'info'

and later accessed or set using the accessor methods #[] and #[]= or a configuration helper. These helpers are defined in the Helpers module and provide easier access to complex configuration options.

Defined Under Namespace

Modules: Helpers Classes: MethodChain

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#default_meta_info, #default_processing_pipeline, #patterns

Constructor Details

#initializeConfiguration

Create a new Configuration object.


122
123
124
125
# File 'lib/webgen/configuration.rb', line 122

def initialize
  @data = {}
  @meta_info = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object

:nodoc:


145
146
147
# File 'lib/webgen/configuration.rb', line 145

def method_missing(id, *args) #:nodoc:
  MethodChain.new(self).method_missing(id, *args)
end

Instance Attribute Details

#dataObject (readonly)

The configuration options hash.


119
120
121
# File 'lib/webgen/configuration.rb', line 119

def data
  @data
end

#meta_infoObject (readonly)

The hash which stores the meta info for the configuration options.


116
117
118
# File 'lib/webgen/configuration.rb', line 116

def meta_info
  @meta_info
end

Instance Method Details

#[](name) ⇒ Object

Return the configuration option name.


128
129
130
131
132
133
134
# File 'lib/webgen/configuration.rb', line 128

def [](name)
  if @data.has_key?(name)
    @data[name]
  else
    raise ArgumentError, "No such configuration option: #{name}"
  end
end

#[]=(name, value) ⇒ Object

Set the configuration option name to the provided value.


137
138
139
140
141
142
143
# File 'lib/webgen/configuration.rb', line 137

def []=(name, value)
  if @data.has_key?(name)
    @data[name] = value
  else
    raise ArgumentError, "No such configuration option: #{name}"
  end
end