Class: Messed::Configuration

Inherits:
Object
  • Object
show all
Includes:
ConfigHelper
Defined in:
lib/messed/configuration.rb

Defined Under Namespace

Modules: ConfigHelper Classes: Application, Interfaces, Queues

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConfigHelper

#with

Constructor Details

#initialize(environments, environment) ⇒ Configuration

Returns a new instance of Configuration.



85
86
87
88
89
90
# File 'lib/messed/configuration.rb', line 85

def initialize(environments, environment)
  @environments, @environment = environments, environment
  @queues = Queues.new
  @interfaces = Interfaces.new
  @application = Application.new
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



82
83
84
# File 'lib/messed/configuration.rb', line 82

def application
  @application
end

#environmentObject (readonly)

Returns the value of attribute environment.



82
83
84
# File 'lib/messed/configuration.rb', line 82

def environment
  @environment
end

#environmentsObject (readonly)

Returns the value of attribute environments.



82
83
84
# File 'lib/messed/configuration.rb', line 82

def environments
  @environments
end

#interfacesObject (readonly)

Returns the value of attribute interfaces.



82
83
84
# File 'lib/messed/configuration.rb', line 82

def interfaces
  @interfaces
end

#log_levelObject

Returns the value of attribute log_level.



83
84
85
# File 'lib/messed/configuration.rb', line 83

def log_level
  @log_level
end

#loggerObject

Returns the value of attribute logger.



83
84
85
# File 'lib/messed/configuration.rb', line 83

def logger
  @logger
end

#queuesObject (readonly)

Returns the value of attribute queues.



82
83
84
# File 'lib/messed/configuration.rb', line 82

def queues
  @queues
end

Class Method Details

.load_from_directory(environment, dir) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/messed/configuration.rb', line 12

def self.load_from_directory(environment, dir)
  environments = []
  Dir[File.join(dir, '*')].each do |file|
    environments << file if File.directory?(file)
  end

  instance = new(environments, environment)

  instance.instance_eval(File.read(File.join(dir, 'environment.rb')), File.join(dir, 'environment.rb'), 1)
  instance.instance_eval(File.read(File.join(dir, 'environments', "#{environment}.rb")), File.join(dir, 'environments', "#{environment}.rb"), 1)

  instance
end