Module: RubyConf

Defined in:
lib/ruby-conf.rb

Defined Under Namespace

Modules: Magic Classes: Config, Loader

Constant Summary collapse

@@__rc_configs =
{}

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



290
# File 'lib/ruby-conf.rb', line 290

def [](name) @@__rc_configs[name.to_sym] end

.clearObject



281
282
283
284
# File 'lib/ruby-conf.rb', line 281

def clear()
  Loader::__rc_set_conf
  @@__rc_configs.clear
end

.define(name = nil, options = {}, &block) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/ruby-conf.rb', line 294

def define(name = nil, options = {}, &block)
  config = Config.new(name, &block)
  @@__rc_configs[name.to_sym] = config unless name.nil?

  const = options.fetch(:as, name)
  if const && const.to_s[/^[A-Z]/]
    const = const.to_sym
    ::Object.const_set(const, config) if !::Object.const_defined?(const) || ::Object.const_get(const).is_a?(Config)
  end

  if Loader::__rc_conf.nil? && (name.nil? || name.to_s =~ /^(?:Rails)?Conf/)
    default_conf = if ::Object.const_defined?(:Rails)
      cfg = config[:"#{::Rails.env}"] || config[:"#{::Rails.env}_conf"] || config[:"#{::Rails.env}_config"]
      (cfg && cfg.detach) || config
    else
      config
    end
    Loader::__rc_set_conf(default_conf)
  end

  config
end

.err(*objs) ⇒ Object



11
# File 'lib/ruby-conf.rb', line 11

def self.err(*objs) self.puts($stderr, *objs) end

.inspectObject



288
# File 'lib/ruby-conf.rb', line 288

def inspect() @@__rc_configs.inspect end

.method_missing(name, *args) ⇒ Object



291
# File 'lib/ruby-conf.rb', line 291

def method_missing(name, *args) @@__rc_configs[name.to_sym] end

.out(*objs) ⇒ Object



12
# File 'lib/ruby-conf.rb', line 12

def self.out(*objs) self.puts($stdout, *objs) end

.puts(logger = $stdout, *obj) ⇒ Object



10
# File 'lib/ruby-conf.rb', line 10

def self.puts(logger = $stdout, *obj) logger.puts(*obj) if logger.respond_to?(:puts) end

.respond_to?(name) ⇒ Boolean

Returns:

  • (Boolean)


292
# File 'lib/ruby-conf.rb', line 292

def respond_to?(name) @@__rc_configs.key?(name.to_sym) end

.to_sObject



286
# File 'lib/ruby-conf.rb', line 286

def to_s() @@__rc_configs.to_s end

.to_strObject



287
# File 'lib/ruby-conf.rb', line 287

def to_str() @@__rc_configs.to_str end