Sha256: c9e8150c7cdd1a771bbc29225c2c9aa166aaacc76c9b19086e63a85e7b7687d8

Contents?: true

Size: 1.18 KB

Versions: 27

Compression:

Stored size: 1.18 KB

Contents

module Rackamole
  module Interceptor
    
    # === For Rails only!
    #
    # Rails handles raised exception in a special way. 
    # Thus special care need to be taken to enable exception to bubble up
    # to the mole.
    #
    # In order for the mole to trap framework exception, you must include
    # the interceptor in your application controller.
    # ie include Rackamole::Interceptor
    def self.included( base )
      base.send( :alias_method_chain, :rescue_action_in_public, :mole )
      base.send( :alias_method_chain, :rescue_action_locally, :mole )
    end
    
    private

      # Instructs the mole to trap the framework exception
      def rescue_action_locally_with_mole( exception )
        # Stuff the exception in the env for mole rack retrieval
        request.env['mole.exception'] = exception
        rescue_action_locally_without_mole( exception )
      end
          
      # Instructs the mole to trap the framework exception
      def rescue_action_in_public_with_mole( exception )
        # Stuff the exception in the env for mole rack retrieval
        request.env['mole.exception'] = exception
        rescue_action_in_public_without_mole( exception )
      end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rackamole-0.4.1 lib/rackamole/interceptor.rb
rackamole-0.4.0 lib/rackamole/interceptor.rb
rackamole-0.3.9 lib/rackamole/interceptor.rb
rackamole-0.3.8 lib/rackamole/interceptor.rb
rackamole-0.3.7 lib/rackamole/interceptor.rb
rackamole-0.3.6 lib/rackamole/interceptor.rb
rackamole-0.3.5 lib/rackamole/interceptor.rb
rackamole-0.3.4 lib/rackamole/interceptor.rb
rackamole-0.3.3 lib/rackamole/interceptor.rb
rackamole-0.3.2 lib/rackamole/interceptor.rb
rackamole-0.3.1 lib/rackamole/interceptor.rb
rackamole-0.3.0 lib/rackamole/interceptor.rb
rackamole-0.2.9 lib/rackamole/interceptor.rb
rackamole-0.2.8 lib/rackamole/interceptor.rb
rackamole-0.2.7 lib/rackamole/interceptor.rb
rackamole-0.2.6 lib/rackamole/interceptor.rb
rackamole-0.2.5 lib/rackamole/interceptor.rb
rackamole-0.2.4 lib/rackamole/interceptor.rb
rackamole-0.2.3 lib/rackamole/interceptor.rb
rackamole-0.2.2 lib/rackamole/interceptor.rb