Sha256: 7b7954ed75d3b0351a97f96eb92c0c2dea5525df4757a5567718f7c894ccdc43

Contents?: true

Size: 974 Bytes

Versions: 4

Compression:

Stored size: 974 Bytes

Contents

module EasyProfiler
  module ActionControllerExtensions
    def self.included(base) #:nodoc:
      base.send :include, InstanceMethods

      base.class_eval do
        after_filter :dump_firebug_profile
      end
    end
    
    module InstanceMethods 
      # Exposes firebug variable where logs can be submitted.
      #
      #   class UserController < ApplicationController
      #     def index
      #       firebug.debug 'Why I can be easily debugging with this thing!'
      #     end
      #   end
      def firebug_logger
        @_firebug_logger ||= FirebugLogger.new
      end
      
      def dump_firebug_profile
        return if firebug_logger.logs.empty?

        logs = firebug_logger.logs.collect do |message|
          # We have to add any escape characters
          "console.info('#{self.class.helpers.escape_javascript(message)}');"
        end.join("\n")

        response.body << self.class.helpers.javascript_tag(logs)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easy-prof-1.1.2 lib/easy_prof/action_controller_extensions.rb
easy-prof-1.1.1 lib/easy_prof/action_controller_extensions.rb
easy-prof-1.1.0 lib/easy_prof/action_controller_extensions.rb
easy-prof-1.0.0 lib/easy_profiler/action_controller_extensions.rb