Class: Figgy
- Inherits:
-
Object
- Object
- Figgy
- Defined in:
- lib/figgy.rb,
lib/figgy/hash.rb,
lib/figgy/store.rb,
lib/figgy/finder.rb,
lib/figgy/version.rb,
lib/figgy/configuration.rb
Overview
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. #=> 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.
Defined Under Namespace
Classes: Configuration, Finder, Hash, Store
Constant Summary
- FileNotFound =
Class.new(StandardError)
- VERSION =
"0.9.1"
Class Method Summary (collapse)
-
+ (Figgy) build {|Figgy::Configuration| ... }
A Figgy instance using the configuration.
Instance Method Summary (collapse)
-
- (Figgy) initialize(config)
constructor
A new instance of Figgy.
- - (Object) inspect
- - (Object) method_missing(m, *args, &block)
Constructor Details
- (Figgy) initialize(config)
A new instance of Figgy
35 36 37 38 39 40 41 42 43 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(m, *args, &block)
45 46 47 |
# File 'lib/figgy.rb', line 45 def method_missing(m, *args, &block) @store.get(m) end |
Class Method Details
+ (Figgy) build {|Figgy::Configuration| ... }
A Figgy instance using the configuration
29 30 31 32 33 |
# File 'lib/figgy.rb', line 29 def self.build(&block) config = Configuration.new block.call(config) new(config) end |
Instance Method Details
- (Object) inspect
49 50 51 52 53 54 55 56 |
# File 'lib/figgy.rb', line 49 def inspect if @store.size > 0 key_names = @store.keys.sort "#<Figgy (#{@store.size} keys): #{key_names.join(' ')}>" else "#<Figgy (empty)>" end end |