module Toast::ConfigDSL
Public Class Methods
get_config(_toast_config, _toast_cfg_name)
click to toggle source
Interprets one config file and stores config info in the @expositions Array using OpenStruct.
Params:
config
- String
-
The configuration file's content as string
fname
- String
-
The file name of the config file with path relative to
Rails.root
Return: nil
# File lib/toast/config_dsl.rb, line 17 def self.get_config _toast_config, _toast_cfg_name # using _toast_ prefix for all locals here, because they end up in the # handler/allow block scope (closure) # also freeze them to prevent accidental changes # is there a way to remove closure vars with instance_eval? _toast_config.freeze _toast_cfg_name.freeze @@cfg_name = _toast_cfg_name @@stack = [] _toast_base = ConfigDSL::Base.new _toast_base.freeze _toast_base.instance_eval(_toast_config, _toast_cfg_name) rescue ArgumentError, NameError => _toast_error _toast_base.raise_config_error _toast_error.message end
get_settings(config, cfg_name)
click to toggle source
Interprets the global settings file and stores data using OpenStruct Params:
config
- String
-
The configuration file's content as string
fname
- String
-
The file name of the config file with path relative to
Rails.root
Return: nil
# File lib/toast/config_dsl.rb, line 44 def self.get_settings config, cfg_name @@cfg_name = cfg_name @@stack = [] # defaults Toast.settings = OpenStruct.new Toast.settings.max_window = 42 Toast.settings.link_unlink_via_post = false Toast.settings.authenticate = lambda{|r| r} settings = ConfigDSL::Settings.new settings.instance_eval(config, cfg_name) rescue ArgumentError, NameError => error settings.raise_config_error error.message end