Class: Axl::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/axl/configuration.rb

Overview

CONFIGURATION CLASS

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, env: nil) ⇒ Configuration

INITIALIZER



40
41
42
43
44
45
46
# File 'lib/axl/configuration.rb', line 40

def initialize(path, env: nil)
  begin
    @config = YAML.load_file(path)[env.to_s]
  rescue Errno::ENOENT
    raise ConfigurationFileNotFoundError.new(path) unless Pathname.new(path).exist?
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

:nodoc:



66
67
68
69
70
71
72
# File 'lib/axl/configuration.rb', line 66

def method_missing(name, *args, &block) # :nodoc:
  if config.has_key? name.to_s
    config[name.to_s]
  else
    super name, *args, &block
  end
end

Class Method Details

.load(path, env: 'production') ⇒ Object



30
31
32
# File 'lib/axl/configuration.rb', line 30

def load(path, env: 'production')
  Configuration.new(path, env: env)
end

Instance Method Details

#to_hObject

PUBLIC



52
53
54
# File 'lib/axl/configuration.rb', line 52

def to_h
  config.dup
end