Class: DslEvaluator::App

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Singleton
Defined in:
lib/dsl_evaluator/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



9
10
11
# File 'lib/dsl_evaluator/app.rb', line 9

def initialize
  @config = defaults
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/dsl_evaluator/app.rb', line 8

def config
  @config
end

Instance Method Details

#configure {|@config| ... } ⇒ Object

Yields:



36
37
38
# File 'lib/dsl_evaluator/app.rb', line 36

def configure
  yield(@config)
end

#default_loggerObject



31
32
33
# File 'lib/dsl_evaluator/app.rb', line 31

def default_logger
  Logger.new(ENV["DSL_EVALUATOR_LOG_PATH"] || $stderr)
end

#defaultsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dsl_evaluator/app.rb', line 13

def defaults
  config = ActiveSupport::OrderedOptions.new

  config.logger = default_logger
  config.logger.formatter = Logger::Formatter.new
  config.logger.level = ENV["DSL_EVALUATOR_LOG_LEVEL"] || :info

  config.on_exception = :raise

  config.root = Dir.pwd

  config.backtrace = ActiveSupport::OrderedOptions.new
  config.backtrace.reject_pattern = nil # dont use .reject. Seems its used internally by ActiveSupport::OrderedOptions
  config.backtrace.select_pattern = nil

  config
end