class Figgy

An instance of Figgy is the object used to provide access to your configuration files. This does very little but recognize missing methods and go look them up as a configuration key.

To create a new instance, you probably want to use Figgy.build:

MyConfig = Figgy.build do |config|
  config.root = '/path/to/my/configs'
end
MyConfig.foo.bar #=> read from /path/to/my/configs/foo.yml

This should maybe be a BasicObject or similar, to provide as many available configuration keys as possible. Maybe.

Constants

FileNotFound
VERSION

Public Class Methods

build(&block) click to toggle source

@yield [Figgy::Configuration] an object to set things up with @return [Figgy] a Figgy instance using the configuration

# File lib/figgy.rb, line 29
def self.build(&block)
  config = Configuration.new
  block.call(config)
  new(config)
end
new(config) click to toggle source
# File lib/figgy.rb, line 35
def initialize(config)
  @config = config
  @finder = Finder.new(config)
  @store  = Store.new(@finder, @config)

  if @config.preload?
    @finder.all_key_names.each { |key| @store.get(key) }
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/figgy.rb, line 45
def [](key)
  @store.get(key)
end
inspect() click to toggle source
# File lib/figgy.rb, line 63
def inspect
  if @store.size > 0
    key_names = @store.keys.sort
    "#<Figgy (#{@store.size} keys): #{key_names.join(' ')}>"
  else
    "#<Figgy (empty)>"
  end
end
method_missing(m, *args, &block) click to toggle source
# File lib/figgy.rb, line 49
def method_missing(m, *args, &block)
  @store.get(m)
end
respond_to?(m, *) click to toggle source
Calls superclass method
# File lib/figgy.rb, line 53
def respond_to?(m, *)
  super || respond_to_missing?(m)
end
respond_to_missing?(m, *) click to toggle source
# File lib/figgy.rb, line 57
def respond_to_missing?(m, *)
  @store.get(m) != nil
rescue Figgy::FileNotFound
  false
end