Class: ConfSources::File

Inherits:
Default show all
Defined in:
lib/confsources.rb

Instance Attribute Summary

Attributes inherited from Default

#options

Instance Method Summary collapse

Methods inherited from Default

#[], #export_to, #is_defined?, #merge, #merge!, #to_a, #to_pairs, #to_s, #validate!

Constructor Details

#initialize(conf_file) ⇒ File


80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/confsources.rb', line 80

def initialize conf_file
    loaded_yaml = YAML.load_file conf_file
    if loaded_yaml.is_a? Hash
        @options = loaded_yaml.select { |k,v| ConfSources::is_option_exist? k.to_sym and not v.nil?
        }.collect { |k,v|
            candidate = ConfMaker::get_options.select{|e|e[:name] == k.to_sym}.first.clone
            candidate[:value] = v
            candidate
        }
    else
        @options = []
    end
end