module Toast::ConfigDSL::Common
Public Class Methods
new(config_data=nil)
click to toggle source
# File lib/toast/config_dsl/common.rb, line 2 def initialize config_data=nil @config_data = config_data end
Public Instance Methods
check_symbol_list(list)
click to toggle source
# File lib/toast/config_dsl/common.rb, line 10 def check_symbol_list list unless list.is_a?(Array) and list.all?{|x| x.is_a? Symbol} raise_config_error "Directive requires a list of symbols.\n"+ " #{list.map{|x| x.inspect}.join(', ')} ?" end end
method_missing(method, *args)
click to toggle source
# File lib/toast/config_dsl/common.rb, line 6 def method_missing method, *args raise_config_error "Unknown directive: `#{method}'" end
raise_config_error(message='')
click to toggle source
# File lib/toast/config_dsl/common.rb, line 17 def raise_config_error message='' match = caller.grep(/#{Toast::ConfigDSL.cfg_name}/).first file_line = if match.nil? Toast::ConfigDSL.cfg_name else match.split(':in').first end message += "\n directive: /#{Toast::ConfigDSL.stack.join('/')}" message += "\n in file : #{file_line}" Toast.raise_config_error message end
stack_push(level) { || ... }
click to toggle source
… to not forget to pop use:
# File lib/toast/config_dsl/common.rb, line 33 def stack_push level, &block Toast::ConfigDSL.stack << level yield Toast::ConfigDSL.stack.pop end