Class: Vanilla::Config

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

Overview

Create a new Vanilla application Configuration options include:

:soup - provide the path to the soup data
:soups - provide an array of paths to soup data
:root - the directory that the soup paths are relative to;
        defaults to Dir.pwd
:renderers - a hash of names to classes
:default_renderer - the class to use when no renderer is provided;
                    defaults to 'Vanilla::Renderers::Base'
:default_layout_snip - the snip to use as a layout when rendering to HTML;
                       defaults to 'layout'
:root_snip - the snip to load for the root ('/') url;
             defaults to 'start'

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  @attributes = {
    :root => Dir.pwd,
    :root_snip => "start",
    :soup => nil,
    :soups => ["soups/base", "soups/system"],
    :default_layout_snip => "layout",
    :default_renderer => Vanilla::Renderers::Base,
    :raise_errors => false,
    :renderers => {
      "base" => Vanilla::Renderers::Base,
      "markdown" => Vanilla::Renderers::Markdown,
      "bold" => Vanilla::Renderers::Bold,
      "erb" => Vanilla::Renderers::Erb,
      "rb" => Vanilla::Renderers::Ruby,
      "ruby" => Vanilla::Renderers::Ruby,
      "haml" => Vanilla::Renderers::Haml,
      "raw" => Vanilla::Renderers::Raw,
      "textile" => Vanilla::Renderers::Textile
    }
  }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, value = nil) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/vanilla/config.rb', line 43

def method_missing(method, value=nil)
  attribute_name = method.to_s.gsub(/=$/, '').to_sym
  if method =~ /=$/
    @attributes[attribute_name] = value
  else
    @attributes[attribute_name]
  end
end