Class: Diagnostics

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

Overview

Used to provide better diagnostics

Instance Method Summary collapse

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

Raises:

  • (ex)


16
17
18
19
# File 'lib/diagnostics.rb', line 16

def method_missing(m, *args, &block)
	ex, msg = *@exceptions[m]
	raise ex, msg
end