Class: MetaInspector::ExceptionLog
- Inherits:
-
Object
- Object
- MetaInspector::ExceptionLog
- Defined in:
- lib/meta_inspector/exception_log.rb
Overview
Stores the exceptions passed to it, warning about them if required
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#warn_level ⇒ Object
readonly
Returns the value of attribute warn_level.
Instance Method Summary collapse
- #<<(exception) ⇒ Object
-
#initialize(options = {}) ⇒ ExceptionLog
constructor
A new instance of ExceptionLog.
- #ok? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ ExceptionLog
Returns a new instance of ExceptionLog.
7 8 9 10 |
# File 'lib/meta_inspector/exception_log.rb', line 7 def initialize( = {}) @warn_level = [:warn_level] || :raise @exceptions = [] end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
5 6 7 |
# File 'lib/meta_inspector/exception_log.rb', line 5 def exceptions @exceptions end |
#warn_level ⇒ Object (readonly)
Returns the value of attribute warn_level.
5 6 7 |
# File 'lib/meta_inspector/exception_log.rb', line 5 def warn_level @warn_level end |
Instance Method Details
#<<(exception) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/meta_inspector/exception_log.rb', line 12 def <<(exception) case warn_level when :raise fail exception when :warn warn exception when :store @exceptions << exception end end |
#ok? ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/meta_inspector/exception_log.rb', line 23 def ok? if warn_level == :store exceptions.empty? else warn 'ExceptionLog#ok? should only be used when warn_level is :store' end end |