Class: MetaInspector::ExceptionLog

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_inspector/exception_log.rb

Overview

Stores the exceptions passed to it, warning about them if required

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ExceptionLog



9
10
11
12
# File 'lib/meta_inspector/exception_log.rb', line 9

def initialize(options = {})
  @exceptions = []
  @warn_level = options[:warn_level]
end

Instance Attribute Details

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



7
8
9
# File 'lib/meta_inspector/exception_log.rb', line 7

def exceptions
  @exceptions
end

#warn_levelObject (readonly)

Returns the value of attribute warn_level.



7
8
9
# File 'lib/meta_inspector/exception_log.rb', line 7

def warn_level
  @warn_level
end

Instance Method Details

#<<(exception) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/meta_inspector/exception_log.rb', line 14

def <<(exception)
  case warn_level
  when :warn
    warn exception
  when :raise
    raise exception
  end

  @exceptions << exception
end

#ok?Boolean



25
26
27
# File 'lib/meta_inspector/exception_log.rb', line 25

def ok?
  exceptions.empty?
end