Module: DynaModel::Config

Extended by:
Config, Options
Included in:
Config
Defined in:
lib/dyna_model/config.rb,
lib/dyna_model/config/options.rb

Overview

:nodoc

Defined Under Namespace

Modules: Options

Instance Method Summary collapse

Methods included from Options

defaults, option, reset, settings

Instance Method Details

#default_loggerObject

The default logger: either the Rails logger or just stdout.



33
34
35
# File 'lib/dyna_model/config.rb', line 33

def default_logger
  defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout)
end

#loggerObject

Returns the assigned logger instance.



38
39
40
# File 'lib/dyna_model/config.rb', line 38

def logger
  @logger ||= default_logger
end

#logger=(logger) ⇒ Object

If you want to, set the logger manually to any output you’d like. Or pass false or nil to disable logging entirely.



43
44
45
46
47
48
49
50
# File 'lib/dyna_model/config.rb', line 43

def logger=(logger)
  case logger
  when false, nil then @logger = nil
  when true then @logger = default_logger
  else
    @logger = logger if logger.respond_to?(:info)
  end
end