Sha256: 6d4b508d3c581f010fe2c5ed00cda79f5cc75eb0f39e5c0bd32439cc65e90ac1

Contents?: true

Size: 1023 Bytes

Versions: 4

Compression:

Stored size: 1023 Bytes

Contents

module Rackamole
  module Interceptor
    
    # In order for the mole to trap framework exception, you must include
    # the interceptor in your application controller.
    # ie include Wackamole::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

4 entries across 4 versions & 1 rubygems

Version Path
rackamole-0.0.6 lib/rackamole/interceptor.rb
rackamole-0.0.4 lib/rackamole/interceptor.rb
rackamole-0.0.3 lib/rackamole/interceptor.rb
rackamole-0.0.2 lib/rackamole/interceptor.rb