Class: Config

Inherits:
Object
  • Object
show all
Extended by:
Dry::Container::Mixin
Includes:
Singleton
Defined in:
lib/rforward/config.rb

Constant Summary collapse

FLUENTD =
:flunetd.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/rforward/config.rb', line 4

def config
  @config
end

#root_pathObject

Returns the value of attribute root_path.



5
6
7
# File 'lib/rforward/config.rb', line 5

def root_path
  @root_path
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
16
# File 'lib/rforward/config.rb', line 13

def [](key)
  config = @config || sample
  config[key.to_s]
end

#create_sample_config(config_path) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rforward/config.rb', line 18

def create_sample_config config_path
  RLogger.instance.info "Config created (#{config_path})"

  File.open(config_path,"w") do |file|
    file.write sample.to_yaml
  end
end

#load_config(config_path) ⇒ Object



9
10
11
# File 'lib/rforward/config.rb', line 9

def load_config config_path
  @config = YAML.load_file config_path
end