Class Module
In: lib/mole/module.rb
Parent: Object

Methods

Public Instance methods

intercepts a feature after the feature is called. During the callback you will have access to the object ( context ) on which the call is intercepted, as well as the arguments/block and return values the feature was issued with.

Example:

  MyClass.mole_after( :feature => :blee ) do |context, feature, ret_val, block, *args|
    Mole::Moler.mole_it( context, feature, context.session[:user_id],
                        :args => args )
  end

This will wrap the method blee with an after interceptor. After the blee call is issued on MyClass, control will be handed to the after interceptor.

Options:

:feature:The name of the feature to be intercepted
:interceptor:The class name of your interceptor class. If no interceptor block is specified
:method:The name of the method to callback the interceptor on once an exception condition has been trapped.

intercepts a feature before the feature is called. During the callback you will have access to the object ( context ) on which the call is intercepted, as well as the arguments/block, the feature was issued with.

Example:

  MyClass.mole_before( :feature => :blee ) do |context, feature, block, *args|
    Mole::Moler.mole_it( context, feature, context.session[:user_id],
                        :args => args )
  end

This will wrap the method blee with a before interceptor. Before the blee call is issued on MyClass, control will be handed to the before interceptor.

Options:

:feature:The name of the feature to be intercepted

If you elect not to use the block form of the call, you can pass in the following arguments to the option hash:

:interceptor:The class name of your interceptor class. If no interceptor block is specified
:method:The name of the method to callback the interceptor on once an exception condition has been trapped.

intercepts a collection of features and wrap performance check based on the specified :perf_threshold. The trigger defaults to 5 secs if not explicitly set.

Example:

  MyClass.mole_perf do |context, action, elapsed_time, ret, block, *args|
    Mole::DbMole.perf_it( context.session[:user_id],
                          :controller   => context.class.name,
                          :action       => action,
                          :elapsed_time => "%3.3f" % elapsed_time )
  end

This will trap all public methods on the MyClass that takes more than :perf_threshold to complete. You can override this default by using the option :features => [m1,m2,…]. This is handy for controller moling rails and merb context.

If you elect not to use the block form of the call, you can pass in the following arguments to the option hash:

:interceptor:The class name of your interceptor class
:method:The name of the method to callback the interceptor on once a perf condition has been trapped.

monitors a collections of features and wrap rescue logic to trap unchecked exceptions. You can handle to trap differently by either logging the event in the db or sending out email/IM notification.

Example:

  MyClass.mole_unchecked do |context, action, boom, block, *args|
    Mole::Moler.check_it( context.session[:user_id],
                         :controller => context.class.name,
                         :action     => action,
                         :boom       => boom )
  end

This will wrap all public instance methods on MyClass. If any of these methods raises an unchecked exception, the MOle will surface the condition. This call also takes in a :features option to specify a list of methods if the default instance methods is not suitable, you can pass in a collection of methods that you wish to mole. This is handy in the case of Rails/Merb where conveniences are provided to gather controller actions

If you elect not to use the block form of the call, you can pass in the following arguments to the option hash:

:interceptor:The class name of your interceptor class
:method:The name of the method to callback the interceptor on once an exception condition has been trapped.

[Validate]