Module: Fluent::DataConfigHelper
- Included in:
- DataConfig
- Defined in:
- lib/fluent/data_config.rb
Instance Method Summary collapse
-
#determine_data_source ⇒ Object
Determines what data source to use.
-
#method_missing(*args, &block) ⇒ Object
This is being used in order to allow a call to any key in a config file.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
This is being used in order to allow a call to any key in a config file. The key will be treated as a method. Since no such method will exist, the method_missing call will handle finding the key in a file.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fluent/data_config.rb', line 10 def method_missing(*args, &block) determine_data_source unless @data_source key = args.first value = @data_source[key.to_s] value = args[1] unless value value end |
Instance Method Details
#determine_data_source ⇒ Object
Determines what data source to use. If this is being called, it means no data source was specified. If an environment variable has been set, that will be used. If no data source can be established, a default data file will be referenced.
25 26 27 28 29 30 |
# File 'lib/fluent/data_config.rb', line 25 def determine_data_source @data_source = nil @data_source = YAML.load_file "#{data_path}/#{ENV['FLUENT_CONFIG_FILE']}" if ENV['FLUENT_CONFIG_FILE'] Fluent::DataConfig.load 'config-data.yml' if @data_source.nil? end |