Class: LocalConf

Inherits:
Hash show all
Includes:
Hash::EasyAccess
Defined in:
lib/vex/base/local_conf.rb

Instance Method Summary collapse

Methods included from Hash::EasyAccess

check, check_key, easy_access, extended, fetch, #respond_to?, set

Methods inherited from Hash

#easy_access, #easy_access!, #easy_accessible?, #insp, #inspect, #with_simple_access

Methods included from Hash::Cross

#cross

Methods included from Hash::Extras

#delete_all, #hmap, included, #select_entries

Methods included from Hash::Compact

#compact, #compact!

Methods included from Hash::Extract

#extract, #extract!

Methods included from Hash::EnsureKeys

#keys?

Constructor Details

#initialize(file) ⇒ LocalConf

Returns a new instance of LocalConf.

Raises:

  • (Errno::ENOENT)


4
5
6
7
8
9
10
11
12
# File 'lib/vex/base/local_conf.rb', line 4

def initialize(file)
  r1 = load file.sub(/\.yml$/, ".defaults.yml")
  r2 = load file

  return if r1 || r2
  
  raise Errno::ENOENT, 
    "Missing configuration file #{App.root}/config/#{file.sub(/\.yml$/, "")}{.defaults}.yml}"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



33
34
35
36
37
38
# File 'lib/vex/base/local_conf.rb', line 33

def method_missing(sym, *args, &block)
  return super unless args.empty? && !block_given? && sym.to_s =~ /(.*)\?/
  !fetch($1.to_sym).blank?
rescue IndexError
  false
end