Class Caesars::Config
In: lib/caesars/config.rb
Parent: Object

Methods

[]   caesars_init   check_paths   dsl   empty?   has_key?   keys   new   postprocess   refresh   verbose=  

Classes and Modules

Class Caesars::Config::ForceRefresh

Attributes

options  [R] 
paths  [RW] 
verbose  [R] 

Public Class methods

Specify a DSL class (glass) to include in this config.

    class CoolDrink < Caesars::Config
      dsl CoolDrink::Flavours::DSL
    end

args is a last of config file paths to load into this instance. If the last argument is a hash, it‘s assumed to be a list of options. The available options are:

<li>:verbose => true or false</li>

Public Instance methods

Provide a hash-like interface for Config classes. name is the name of a DSL config.

    class CoolDrink < Caesars::Config
      dsl CoolDrink::Flavours::DSL
    end

    cd = CoolDrink.new('/path/2/config')
    cd[:flavours]     # => {}

Reset all config instance variables to nil.

Checks all values of +@paths+, raises an exception for nil values and file paths that don‘t exist.

Do any of the known DSLs have config data?

Is name a known configuration type?

    class CoolDrink < Caesars::Config
      dsl CoolDrink::Flavours::DSL
    end

    cd = CoolDrink.new('/path/2/config')
    cd.has_key?(:taste)        # => false
    cd.has_key?(:flavours)     # => true

Returns the list of known DSL config names.

    class CoolDrink < Caesars::Config
      dsl CoolDrink::Flavours::DSL
    end

    cd = CoolDrink.new('/path/2/config')
    cd.keys           # => [:flavours]

This method is a stub. It gets called by refresh after each config file has be loaded. You can use it to run file specific processing on the configuration before it‘s used elsewhere.

Clear all current configuration (sets all config instance variables to nil) and reload all config files in +@paths+. After each path is loaded, Caesars::Config.postprocess is called. If a ForceRefresh exception is raise, refresh is run again from the start. This is useful in the case where one DSL can affect the parsing of another. Note that refresh only clears the instance variables, the class vars for each of the DSLs are not affected so all calls to forced_array, forced_hash, chill and forced_ignore are unaffected.

Rudy has an example of forced refreshing in action. See the files (github.com/solutious/rudy):

  • +lib/rudy/config.rb+
  • +lib/rudy/config/objects.rb+.

[Validate]