Class: Rack::Auth::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/auth/ldap.rb

Overview

Note:

this class is not provide to be used standalone

class Config provide Yaml config mapping for Rack::Auth::Module the class map ldap configurations values

Instance Method Summary collapse

Constructor Details

#initialize(options = { :file => './ldap.yml'}) ⇒ Config

initializer for Config class

Parameters:

  • options (Hash<Symbol>) (defaults to: { :file => './ldap.yml'})

    initialisation options

Options Hash (options):

  • :file (Symbol)

    The YAML filename (default to ./ldap.yml, the config.ru path)



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rack/auth/ldap.rb', line 27

def initialize(options = { :file => './ldap.yml'})
  @values = defaults
  options.merge!(:file => './ldap.yml') { |key,oldval,newval| oldval }
  target  = (ENV['RACK_ENV'])? ENV['RACK_ENV'] : 'test'
  config_values = load_yaml(::File.expand_path(options[:file], Dir.pwd))[target]
  debug = ::File.open("/tmp/test.txt",'a+')
  debug.puts ENV['RACK_ENV']
  debug.close
  config_values.keys.each do |key|
    config_values[key.to_sym] = config_values.delete(key)
  end
  @values.merge! config_values
  @values.keys.each do |meth|
    bloc = Proc.new  {@values[meth] }
      self.class.send :define_method, meth, &bloc
  end
end