Class: Configuration

Inherits:
Section show all
Defined in:
lib/madvertise/ext/config.rb

Overview

The Configuration class provides a simple interface to configuration stored inside of YAML files.

Defined Under Namespace

Modules: Helpers

Instance Method Summary collapse

Methods inherited from Section

from_hash, #mixin

Methods inherited from Hash

#deep_merge, #deep_merge!

Constructor Details

#initialize(mode = :development) {|config| ... } ⇒ Configuration

Create a new Configuration object.

Parameters:

  • mode (Symbol) (defaults to: :development)

    The mode to load from the configurtion file (production, development, etc)

Yields:

  • (config)

    The new configuration object.



95
96
97
98
# File 'lib/madvertise/ext/config.rb', line 95

def initialize(mode = :development)
  @mode = mode
  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Section

Instance Method Details

#load_mixins(path, mixins_to_use) ⇒ void

This method returns an undefined value.

Load given mixins from path.

Parameters:

  • path (String)

    The path to mixin files.

  • mixins_to_use (Array)

    A list of mixins to load from path.



105
106
107
108
109
110
111
# File 'lib/madvertise/ext/config.rb', line 105

def load_mixins(path, mixins_to_use)
  mixins_to_use.map do |mixin_name|
    File.join(path, "#{mixin_name}.yml")
  end.each do |mixin_file|
    mixin(mixin_file)
  end
end