Class: Diagnostics
- Inherits:
-
Object
- Object
- Diagnostics
- Defined in:
- lib/diagnostics.rb
Overview
Used to provide better diagnostics
Instance Method Summary collapse
-
#initialize(owner, exceptions = {}) ⇒ Diagnostics
constructor
A new instance of Diagnostics.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(owner, exceptions = {}) ⇒ Diagnostics
Returns a new instance of Diagnostics.
11 12 13 14 |
# File 'lib/diagnostics.rb', line 11 def initialize(owner, exceptions={}) @owner = owner @exceptions = Hash.new { |h,k| [NoMethodError, "undefined method `#{k}' for #{@owner.inspect}"] }.merge(exceptions) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
16 17 18 19 |
# File 'lib/diagnostics.rb', line 16 def method_missing(m, *args, &block) ex, msg = *@exceptions[m] raise ex, msg end |