Sha256: e162f79ff35129478ba3dc8127fc05cab1f0baa615e06d0a1245d7c7026e8cb3

Contents?: true

Size: 729 Bytes

Versions: 11

Compression:

Stored size: 729 Bytes

Contents

module Bullet
  module Notification
    class NPlusOneQuery < Base
      def initialize( callers, base_class, associations, path = nil )
        super( base_class, associations, path )

        @callers = callers
      end

      def body_with_caller
        "#{body}\n#{call_stack_messages}"
      end
      
      def body
        "#{klazz_associations_str}\n  Add to your finder: #{associations_str}"
      end

      def title
        "N+1 Query #{@path ? "in #{@path}" : 'detected'}"
      end

      protected
      def call_stack_messages
        @callers.collect do |c|
          [ 'N+1 Query method call stack', 
            c.collect {|line| "  #{line}"} ].flatten
        end.join( "\n" )
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
bullet-2.2.1 lib/bullet/notification/n_plus_one_query.rb
bullet-2.2.0 lib/bullet/notification/n_plus_one_query.rb
bullet-2.1.0 lib/bullet/notification/n_plus_one_query.rb
thaold-bullet-2.0.2 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.1 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0.rc3 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0.rc2 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0.rc1 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0.beta.4 lib/bullet/notification/n_plus_one_query.rb
bullet-2.0.0.beta.3 lib/bullet/notification/n_plus_one_query.rb