Module: Raad::Configuration

Extended by:
Configuration
Included in:
Configuration
Defined in:
lib/raad/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object (private)



37
38
39
40
41
42
43
# File 'lib/raad/configuration.rb', line 37

def method_missing(sym, *args)
  if sym.to_s =~ /(.+)=$/
    config[$1] = args.first
  else
    config[sym]
  end
end

Class Method Details

.init(&block) ⇒ Object



5
6
7
# File 'lib/raad/configuration.rb', line 5

def self.init(&block)
  instance_eval(&block) 
end

Instance Method Details

#[](key) ⇒ Object



9
10
11
# File 'lib/raad/configuration.rb', line 9

def [](key)
  config[key]
end

#load(file = nil) ⇒ Nil

Loads a configuration file and eval its content in the service object context

Parameters:

  • file (String) (defaults to: nil)

    The file to load, if not set will use ./config/servive_name

Returns:

  • (Nil)


17
18
19
20
# File 'lib/raad/configuration.rb', line 17

def load(file = nil)
  return unless File.exists?(file)
  self.instance_eval(IO.read(file))
end