Class: Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bottlerocket/models/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(field, *args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bottlerocket/models/configuration.rb', line 40

def method_missing(field, *args)
  begin
    if environments.include? field.to_s
      ConnectionHelper.new attrs[field.to_s]
    else
      attrs[field.to_s]
    end
  rescue
    super(field, *args)
  end
end

Instance Attribute Details

#config_file_locationObject

Returns the value of attribute config_file_location.



26
27
28
# File 'lib/bottlerocket/models/configuration.rb', line 26

def config_file_location
  @config_file_location
end

Instance Method Details

#attrsObject



28
29
30
# File 'lib/bottlerocket/models/configuration.rb', line 28

def attrs
  @attrs ||= YAML.load_file config_file_location
end

#content_typesObject



36
37
38
# File 'lib/bottlerocket/models/configuration.rb', line 36

def content_types
  @content_types ||= ContentTypes.load(content_types_file)
end

#environmentsObject



32
33
34
# File 'lib/bottlerocket/models/configuration.rb', line 32

def environments
  %w(development test staging production)
end