class RBT::Configuration::SimpleConfigurationLoader
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
array_available_methods?()
click to toggle source
iterate_over_the_yaml_files()
click to toggle source
#¶ ↑
iterate_over_the_yaml_files
¶ ↑
#¶ ↑
# File lib/rbt/configuration/simple_configuration_loader.rb, line 70 def iterate_over_the_yaml_files _ = @yaml_files.sort # ======================================================================= # # Batch-load all .yml files next, that reside under rbt/configuration/. # The respective files are, for example, "email.yml" and so forth. # ======================================================================= # unless _.empty? _.each {|this_yaml_file| # =================================================================== # # Load up the data from this yaml file first. # =================================================================== # data = YAML.load_file(this_yaml_file) name_of_the_method_that_is_to_be_defined = File.basename( this_yaml_file.sub(/\.yml$/,'') # We don't need the .yml part afterwards. ).to_sym # =================================================================== # # Register which automatically defined methods will be available. # =================================================================== # @array_available_methods << name_of_the_method_that_is_to_be_defined # =================================================================== # # Next, sanitize Boolean values here. # =================================================================== # if data.is_a? String if data.include? '$' # =============================================================== # # Obtain the value of that particular environment setting next. # =============================================================== # data = RBT.convert_global_env(data).dup if File.directory?(data) and !data.end_with?('/') data << '/' # Directories will have a trailing '/' character. end end # ================================================================= # # Sanitize the data-entry towards a boolean value, if it is either # "f" or "t". # ================================================================= # case data when 'f' data = false when 't' data = true end end # =================================================================== # # Define setters - these will have a trailing '=' character. # =================================================================== # this_method_setter = ( "#{name_of_the_method_that_is_to_be_defined}=" ).to_sym # =================================================================== # # Add these setters to the array that registered these # methods. # =================================================================== # @array_available_methods << this_method_setter self.class.class_eval { # ================================================================= # # Also set a corresponding instance variable. # ================================================================= # instance_variable_set( ('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym, data ) define_method(name_of_the_method_that_is_to_be_defined.to_sym) { self.class.class_eval { instance_variable_get(('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym) } } define_method(this_method_setter) {|input_argument| self.class.class_eval { instance_variable_set(('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym, input_argument) } } } } end end
obtain_all_available_yaml_files( from_this_dir = ::RBT.rbt_configuration_directory? )
click to toggle source
#¶ ↑
obtain_all_available_yaml_files
¶ ↑
This method will fetch every available .yml file that is part of the “configuration system” for the RBT
.
#¶ ↑
# File lib/rbt/configuration/simple_configuration_loader.rb, line 61 def obtain_all_available_yaml_files( from_this_dir = ::RBT.rbt_configuration_directory? ) @yaml_files = Dir["#{from_this_dir}*.yml"] end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/rbt/configuration/simple_configuration_loader.rb, line 40 def reset # ======================================================================= # # Array @array_available_methods will determine which methods are # available on this class. # ======================================================================= # @array_available_methods = [] end