class Figi::Config
Core class
Public Class Methods
from_json(path)
click to toggle source
Load config from json file
@param path [String] File path @example
Figi::Config.from_json('config/config.json')
# File lib/figi/config.rb, line 28 def from_json(path) instance._figi_load(JSON.parse(File.read(path))) end
from_yaml(path)
click to toggle source
Load config from yaml file
@param path File path @example
Figi::Config.from_yaml('config/config.yml')
# File lib/figi/config.rb, line 37 def from_yaml(path) instance._figi_load(YAML.safe_load(File.read(path))) end
load(config = {}, &block)
click to toggle source
Load config from hash
@param config [Hash] Config
@example
Figi::Config.load(host: 'localhost', port: '27017') figi.host # => localhost Figi::Config.load do |config| config.host = 'localhost' config.port = '27017' end figi.host # => localhost
# File lib/figi/config.rb, line 55 def load(config = {}, &block) instance._figi_load(config, &block) end
new()
click to toggle source
Constructor
# File lib/figi/config.rb, line 62 def initialize @table = Hashie::Mash.new end
Public Instance Methods
_figi_load(config = {}) { |table| ... }
click to toggle source
Load config from hash, don't use this directly
@param config [Hash] Config
# File lib/figi/config.rb, line 69 def _figi_load(config = {}) if @table.nil? @table = Hashie::Mash.new(config) else @table.update(config) end yield @table if block_given? end
method_missing(mid, *args)
click to toggle source
Dispatch to Hashie::Mash
# File lib/figi/config.rb, line 81 def method_missing(mid, *args) @table.send(mid, *args) end