Class: Dawn::SafeExtension::SafeContext

Inherits:
Object
  • Object
show all
Defined in:
lib/dawn/api/safe/safe_extension.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ SafeContext

Returns a new instance of SafeContext.

Parameters:

  • obj (Object)


10
11
12
13
# File 'lib/dawn/api/safe/safe_extension.rb', line 10

def initialize(obj)
  @obj = obj
  @last_exception = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

:nodoc:



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dawn/api/safe/safe_extension.rb', line 16

def method_missing(sym, *args, &block)
  if @obj.respond_to?(sym)
    begin
      @obj.send sym, *args, &block
    rescue => ex
      self.last_exception = ex
      false
    end
  else
    @obj.method_missing sym, *args, &block
  end
end

Instance Attribute Details

#last_exceptionObject

Returns the value of attribute last_exception.



5
6
7
# File 'lib/dawn/api/safe/safe_extension.rb', line 5

def last_exception
  @last_exception
end