Class: Bkblz::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/bkblz/config.rb

Constant Summary collapse

CONFIG_VARS =
{
  :application_key => '',
  :account_id => '',
  :debug_http => false,

  :log_device => :stderr, # [:stdout, :stderr, :devnull, path, fd]
  :log_level => :warn, # [:debug, :info, :warn, :error, :fatal, (-6..-1)]
  :log_colorize => true,

  :large_file_max_chunk_size => 1e8, # 100MB
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**config_map) ⇒ Config

Returns a new instance of Config.



19
20
21
22
23
24
25
26
# File 'lib/bkblz/config.rb', line 19

def initialize(**config_map)
  config_map.each do |k,v|
    # allows attr_reader methods from CONFIG_VAR to work
    instance_variable_set :"@#{k}", v
  end

  @config_map = config_map
end

Class Method Details

.configure(config = nil, &block) ⇒ Object



29
30
31
32
33
# File 'lib/bkblz/config.rb', line 29

def configure(config=nil, &block)
  map = config ? config.config_map : CONFIG_VARS.dup
  map = yield map if block_given?
  Config.new map
end