class Falcore::Config

Public Class Methods

from_file(path) click to toggle source
# File lib/falcore/config.rb, line 22
def from_file(path)
  contents = File.read(File.expand_path(path))
  parse(contents)
rescue Errno::ENOENT
  raise "No config found at '#{path}'!"
end
parse(contents) click to toggle source
# File lib/falcore/config.rb, line 29
def parse(contents)
  Parser.new(contents).parse
end

Public Instance Methods

method_missing(m, *args, &block) click to toggle source

@private

# File lib/falcore/config.rb, line 90
def method_missing(m, *args, &block)
  key = m.to_s

  if key.include?('=')
    set(key.delete('='), args.first)
  else
    if has_key?(key)
      get(key)
    else
      NullObject.new
    end
  end
end
respond_to_missing?(m, include_private = false) click to toggle source

@private

Calls superclass method
# File lib/falcore/config.rb, line 105
def respond_to_missing?(m, include_private = false)
  key = m.to_s

  if key.include?('=')
    true
  else
    has_key?(key) || super
  end
end

Private Instance Methods

get(key) click to toggle source
# File lib/falcore/config.rb, line 117
def get(key)
  self[key]
end
set(key, value) click to toggle source
# File lib/falcore/config.rb, line 121
def set(key, value)
  self[key] = value
end