Module: SafeblockModule

Defined in:
lib/safeblock/safeblock_module.rb

Instance Method Summary collapse

Instance Method Details

#rescue_method(method_name, options = {}) ⇒ Object

add macro to use inside classes the macro must accept a method name and optionally a options hash

example of use:

rescue_method :my_method, {:threaded => true}
rescue_method :my_method, {:timeout => 3}
rescue_method :my_method


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/safeblock/safeblock_module.rb', line 13

def rescue_method(method_name, options = {})
  alias_method :"old_safeblock_#{method_name}", :"#{method_name}"

  define_method :"#{method_name}" do |*args,&block|
  SafeBlock.start(options) do
    instance_eval do
      send :"old_safeblock_#{method_name}", *args, &block
    end

  end
  end
end