Module: Adhearsion::Configuration::ConfigurationEntryPoint

Included in:
Adhearsion::Configuration, AbstractConfiguration
Defined in:
lib/adhearsion/initializer/configuration.rb

Instance Method Summary collapse

Instance Method Details

#add_configuration_for(name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/adhearsion/initializer/configuration.rb', line 4

def add_configuration_for(name)
  configuration_class_name = "#{name}Configuration"
  lowercased_name          = name.to_s.underscore

  class_eval(<<-EVAL, __FILE__, __LINE__)
    def enable_#{lowercased_name}(configuration_options = {})
      @#{lowercased_name}_configuration = #{configuration_class_name}.new(configuration_options)
    end

    def #{lowercased_name}
      @#{lowercased_name}_configuration
    end

    def #{lowercased_name}_enabled?
      !#{lowercased_name}.nil?
    end
  EVAL
end