Class: Cuca::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/cuca/config.rb

Overview

Configure the application

App::Config is normally called from conf/environment.rb . The attributes below the framework will make use of, but you can always define own ones.

Example

Cuca::App.configure do |conf|
    conf.include_directories = %{_widgets _special_widgets}
    conf.database            = 'mydb'		# application specific
end

Attributes:

The file conf/environment.rb within your application path contains a full list of attributes you can set.

Instance Method Summary collapse

Constructor Details

#initializeConfig

some default stuff



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cuca/config.rb', line 43

def initialize
  self['include_directories'] = %w{_controllers _widgets _layouts}
  self['log_level']  = 3
  self['magic_prefix'] = '__default_'
  self['session_key'] = 'cuca_session'
  self['session_prefix'] = 'cuca.'
  self['session_valid'] = 3600*24
  self['view_directory'] = 'app/_views'	# where to find views for the view/erb generator
  self['http_404'] = '404.html'
  self['http_500'] = '500.html'
  self['default_mime_type'] = 'text/html'
  self['display_errors'] = true
  self['http_static_content_expires'] = 300	# expires http header for static content (only if served by the dispatcher)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *params) ⇒ Object

Raises:

  • (NoMethodError)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cuca/config.rb', line 22

def method_missing(m, *params)
    met = m.id2name

#    raise NoMethodError 
    if met[met.size-1].chr == '=' then
      self[met[0..met.size-2]] = params[0]
      return
    end

    if met[-2..-1] == '<<' then
      self[met[0..met.size-3]] ||= []
      self[met[0..met.size-3]] << params[0]
      return
    end

    return self[met] unless self[met].nil?
  
   raise NoMethodError
end