Class: LocalConf

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

Instance Method Summary collapse

Methods included from Hash::Slop

#respond_to?

Methods inherited from Hash

#delete_multi, #insp, #inspect, #slop!, #sloppy?

Methods included from Hash::EnsureKeys

#keys?

Methods included from Hash::Extract

#extract, #extract!

Methods included from Hash::Compact

#compact, #compact!

Methods included from Hash::Extras

#delete_all, #hmap, included, #select_entries

Methods included from Hash::Cross

#cross

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