repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/support/rack_double.rb | spec/support/rack_double.rb | # frozen_string_literal: true
module Support
class AppDouble
def call(_env)
env = @env
[status, headers, response]
end
attr_writer :status
attr_writer :headers
def headers
@headers ||= { 'Content-Type' => 'text/html' }
@headers
end
attr_writer :response
pr... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/integration/counter_cache_spec.rb | spec/integration/counter_cache_spec.rb | # frozen_string_literal: true
require 'spec_helper'
if !mongoid? && active_record?
describe Bullet::Detector::CounterCache do
before(:each) { Bullet.start_request }
after(:each) { Bullet.end_request }
it 'should need counter cache with all cities' do
Country.all.each { |country| country.cities.s... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/integration/mongoid/association_spec.rb | spec/integration/mongoid/association_spec.rb | # frozen_string_literal: true
require 'spec_helper'
if mongoid?
describe Bullet::Detector::Association do
context 'embeds_many' do
context 'posts => users' do
it 'should detect nothing' do
Mongoid::Post.all.each { |post| post.users.map(&:name) }
Bullet::Detector::UnusedEagerLoa... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/integration/active_record/association_spec.rb | spec/integration/active_record/association_spec.rb | # frozen_string_literal: true
require 'spec_helper'
if active_record?
describe Bullet::Detector::Association, 'has_many' do
context 'post => comments' do
it 'should detect non preload post => comments' do
Post.all.each { |post| post.comments.map(&:name) }
Bullet::Detector::UnusedEagerLoadi... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | true |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/student.rb | spec/models/student.rb | # frozen_string_literal: true
class Student < ActiveRecord::Base
has_and_belongs_to_many :teachers
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/entry.rb | spec/models/entry.rb | # frozen_string_literal: true
class Entry < ActiveRecord::Base
belongs_to :category
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/base_user.rb | spec/models/base_user.rb | # frozen_string_literal: true
class BaseUser < ActiveRecord::Base
has_many :comments
has_many :posts
belongs_to :newspaper
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/group.rb | spec/models/group.rb | # frozen_string_literal: true
class Group < ActiveRecord::Base
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/relationship.rb | spec/models/relationship.rb | # frozen_string_literal: true
class Relationship < ActiveRecord::Base
belongs_to :firm
belongs_to :client
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/page.rb | spec/models/page.rb | # frozen_string_literal: true
class Page < Document
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/pet.rb | spec/models/pet.rb | # frozen_string_literal: true
class Pet < ActiveRecord::Base
belongs_to :person, counter_cache: true
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/city.rb | spec/models/city.rb | # frozen_string_literal: true
class City < ActiveRecord::Base
belongs_to :country
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/country.rb | spec/models/country.rb | # frozen_string_literal: true
class Country < ActiveRecord::Base
has_many :cities
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/category.rb | spec/models/category.rb | # frozen_string_literal: true
class Category < ActiveRecord::Base
has_many :posts, inverse_of: :category
has_many :entries
has_many :users
def draft_post
posts.draft.first_or_create
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/teacher.rb | spec/models/teacher.rb | # frozen_string_literal: true
class Teacher < ActiveRecord::Base
has_and_belongs_to_many :students
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/address.rb | spec/models/address.rb | # frozen_string_literal: true
class Address < ActiveRecord::Base
belongs_to :company
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/author.rb | spec/models/author.rb | # frozen_string_literal: true
class Author < ActiveRecord::Base
has_many :documents
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/comment.rb | spec/models/comment.rb | # frozen_string_literal: true
class Comment < ActiveRecord::Base
belongs_to :post, inverse_of: :comments
belongs_to :author, class_name: 'BaseUser'
validates :post, presence: true
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/writer.rb | spec/models/writer.rb | # frozen_string_literal: true
class Writer < BaseUser
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/attachment.rb | spec/models/attachment.rb | # frozen_string_literal: true
class Attachment < ActiveRecord::Base
belongs_to :submission
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/post.rb | spec/models/post.rb | # frozen_string_literal: true
class Post < ActiveRecord::Base
belongs_to :category, inverse_of: :posts
belongs_to :writer
has_many :comments, inverse_of: :post
has_and_belongs_to_many :deals
validates :category, presence: true
scope :preload_comments, -> { includes(:comments) }
scope :in_category_name,... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/submission.rb | spec/models/submission.rb | # frozen_string_literal: true
class Submission < ActiveRecord::Base
belongs_to :user
has_many :replies
has_one :attachment
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/folder.rb | spec/models/folder.rb | # frozen_string_literal: true
class Folder < Document
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/client.rb | spec/models/client.rb | # frozen_string_literal: true
class Client < ActiveRecord::Base
belongs_to :group
has_many :relationships
has_many :firms, through: :relationships
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/role.rb | spec/models/role.rb | # frozen_string_literal: true
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :resource, polymorphic: true
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/newspaper.rb | spec/models/newspaper.rb | # frozen_string_literal: true
class Newspaper < ActiveRecord::Base
has_many :writers, class_name: 'BaseUser'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/person.rb | spec/models/person.rb | # frozen_string_literal: true
class Person < ActiveRecord::Base
has_many :pets
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/reply.rb | spec/models/reply.rb | # frozen_string_literal: true
class Reply < ActiveRecord::Base
belongs_to :submission
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/deal.rb | spec/models/deal.rb | # frozen_string_literal: true
class Deal < ActiveRecord::Base
has_and_belongs_to_many :posts
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/firm.rb | spec/models/firm.rb | # frozen_string_literal: true
class Firm < ActiveRecord::Base
has_many :relationships
has_many :clients, through: :relationships
has_many :groups, through: :clients
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/document.rb | spec/models/document.rb | # frozen_string_literal: true
class Document < ActiveRecord::Base
has_many :children, class_name: 'Document', foreign_key: 'parent_id'
belongs_to :parent, class_name: 'Document', foreign_key: 'parent_id'
belongs_to :author
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/company.rb | spec/models/company.rb | # frozen_string_literal: true
class Company < ActiveRecord::Base
has_one :address
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/user.rb | spec/models/user.rb | # frozen_string_literal: true
class User < ActiveRecord::Base
has_one :submission
has_one :submission_attachment, through: :submission, source: :attachment, class_name: 'Attachment'
belongs_to :category
has_and_belongs_to_many :roles
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/entry.rb | spec/models/mongoid/entry.rb | # frozen_string_literal: true
class Mongoid::Entry
include Mongoid::Document
field :name
belongs_to :category, class_name: 'Mongoid::Category'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/category.rb | spec/models/mongoid/category.rb | # frozen_string_literal: true
class Mongoid::Category
include Mongoid::Document
field :name
has_many :posts, class_name: 'Mongoid::Post'
has_many :entries, class_name: 'Mongoid::Entry'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/address.rb | spec/models/mongoid/address.rb | # frozen_string_literal: true
class Mongoid::Address
include Mongoid::Document
field :name
belongs_to :company, class_name: 'Mongoid::Company'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/comment.rb | spec/models/mongoid/comment.rb | # frozen_string_literal: true
class Mongoid::Comment
include Mongoid::Document
field :name
belongs_to :post, class_name: 'Mongoid::Post'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/post.rb | spec/models/mongoid/post.rb | # frozen_string_literal: true
class Mongoid::Post
include Mongoid::Document
field :name
has_many :comments, class_name: 'Mongoid::Comment'
belongs_to :category, class_name: 'Mongoid::Category'
embeds_many :users, class_name: 'Mongoid::User'
scope :preload_comments, -> { includes(:comments) }
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/company.rb | spec/models/mongoid/company.rb | # frozen_string_literal: true
class Mongoid::Company
include Mongoid::Document
field :name
has_one :address, class_name: 'Mongoid::Address'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/models/mongoid/user.rb | spec/models/mongoid/user.rb | # frozen_string_literal: true
class Mongoid::User
include Mongoid::Document
field :name
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/stack_trace_filter_spec.rb | spec/bullet/stack_trace_filter_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
RSpec.describe StackTraceFilter do
let(:dummy_class) { Class.new { extend StackTraceFilter } }
let(:root_path) { Dir.pwd }
let(:bundler_path) { Bundler.bundle_path }
describe '#caller_in_project' do
it 'gets the caller in the p... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/rack_spec.rb | spec/bullet/rack_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
describe Rack do
let(:middleware) { Bullet::Rack.new app }
let(:app) { Support::AppDouble.new }
context '#html_request?' do
it 'should be true if Content-Type is text/html and http body contains html tag' do
headers = { 'Co... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/notification_collector_spec.rb | spec/bullet/notification_collector_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
describe NotificationCollector do
subject { NotificationCollector.new.tap { |collector| collector.add('value') } }
context '#add' do
it 'should add a value' do
subject.add('value1')
expect(subject.collection).to be_incl... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/detector/counter_cache_spec.rb | spec/bullet/detector/counter_cache_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
module Bullet
module Detector
describe CounterCache do
before :all do
@post1 = Post.first
@post2 = Post.last
end
context '.add_counter_cache' do
it 'should create notification if conditions ... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/detector/association_spec.rb | spec/bullet/detector/association_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
module Bullet
module Detector
describe Association do
before :all do
@post1 = Post.first
@post2 = Post.last
end
context '.add_object_association' do
it 'should add object, associations pair'... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/detector/unused_eager_loading_spec.rb | spec/bullet/detector/unused_eager_loading_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
module Bullet
module Detector
describe UnusedEagerLoading do
before(:all) do
@post = Post.first
@post2 = Post.all[1]
@post3 = Post.last
end
context '.call_associations' do
it 'should... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/detector/n_plus_one_query_spec.rb | spec/bullet/detector/n_plus_one_query_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'ostruct'
using Bullet::Ext::Object
module Bullet
module Detector
describe NPlusOneQuery do
before(:all) do
@post = Post.first
@post2 = Post.last
end
context '.call_association' do
it 'should add call_object_... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/detector/base_spec.rb | spec/bullet/detector/base_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Detector
describe Base do
end
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/notification/counter_cache_spec.rb | spec/bullet/notification/counter_cache_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Notification
describe CounterCache do
subject { CounterCache.new(Post, %i[comments votes]) }
it { expect(subject.body).to eq(' Post => [:comments, :votes]') }
it { expect(subject.title).to eq('Need Counter Cache with Ac... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/notification/unused_eager_loading_spec.rb | spec/bullet/notification/unused_eager_loading_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Notification
describe UnusedEagerLoading do
subject { UnusedEagerLoading.new([''], Post, %i[comments votes], 'path') }
it do
expect(subject.body).to eq(
" Post => [:comments, :votes]\n Remove from your quer... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/notification/n_plus_one_query_spec.rb | spec/bullet/notification/n_plus_one_query_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Notification
describe NPlusOneQuery do
subject { NPlusOneQuery.new([%w[caller1 caller2]], Post, %i[comments votes], 'path') }
it do
expect(subject.body_with_caller).to eq(
" Post => [:comments, :votes]\n Ad... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/notification/base_spec.rb | spec/bullet/notification/base_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Notification
describe Base do
subject { Base.new(Post, %i[comments votes]) }
context '#title' do
it 'should raise NoMethodError' do
expect { subject.title }
.to raise_error(NoMethodError)
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/ext/string_spec.rb | spec/bullet/ext/string_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::String
describe String do
context 'bullet_class_name' do
it 'should only return class name' do
expect('Post:1'.bullet_class_name).to eq('Post')
end
it 'should return class name with namespace' do
expect('Mongoid::Post:1... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/ext/object_spec.rb | spec/bullet/ext/object_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
describe Object do
context 'bullet_key' do
it 'should return class and id composition' do
post = Post.first
expect(post.bullet_key).to eq("Post:#{post.id}")
end
if mongoid?
it 'should return class with name... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/registry/association_spec.rb | spec/bullet/registry/association_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Registry
describe Association do
subject { Association.new.tap { |association| association.add(%w[key1 key2], 'value') } }
context '#merge' do
it 'should merge key/value' do
subject.merge('key0', 'value0')
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/registry/object_spec.rb | spec/bullet/registry/object_spec.rb | # frozen_string_literal: true
require 'spec_helper'
using Bullet::Ext::Object
module Bullet
module Registry
describe Object do
let(:post) { Post.first }
let(:another_post) { Post.last }
subject { Object.new.tap { |object| object.add(post.bullet_key) } }
context '#include?' do
i... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/spec/bullet/registry/base_spec.rb | spec/bullet/registry/base_spec.rb | # frozen_string_literal: true
require 'spec_helper'
module Bullet
module Registry
describe Base do
subject { Base.new.tap { |base| base.add('key', 'value') } }
context '#[]' do
it 'should get value by key' do
expect(subject['key']).to eq(Set.new(%w[value]))
end
end
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet.rb | lib/bullet.rb | # frozen_string_literal: true
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/module/delegation'
require 'set'
require 'uniform_notifier'
require 'bullet/ext/object'
require 'bullet/ext/string'
require 'bullet/dependency'
require 'bullet/stack_trace_filter'
module Bullet
extend... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/generators/bullet/install_generator.rb | lib/generators/bullet/install_generator.rb | # frozen_string_literal: true
module Bullet
module Generators
class InstallGenerator < ::Rails::Generators::Base
desc <<~DESC
Description:
Enable bullet in development/test for your application.
DESC
def enable_in_development
environment(nil, env: 'development') do
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid7x.rb | lib/bullet/mongoid7x.rb | # frozen_string_literal: true
module Bullet
module Mongoid
def self.enable
require 'mongoid'
require 'rubygems'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_m... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_job.rb | lib/bullet/active_job.rb | # frozen_string_literal: true
module Bullet
module ActiveJob
def self.included(base)
base.class_eval do
around_perform do |_job, block|
Bullet.profile { block.call }
end
end
end
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid8x.rb | lib/bullet/mongoid8x.rb | module Bullet
module Mongoid
def self.enable
require 'mongoid'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_method :origin_eager_load, :eager_load
def first... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/version.rb | lib/bullet/version.rb | # frozen_string_literal: true
module Bullet
VERSION = '8.1.0'
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record72.rb | lib/bullet/active_record72.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid4x.rb | lib/bullet/mongoid4x.rb | # frozen_string_literal: true
module Bullet
module Mongoid
def self.enable
require 'mongoid'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_method :origin_eager_load,... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record81.rb | lib/bullet/active_record81.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record70.rb | lib/bullet/active_record70.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record80.rb | lib/bullet/active_record80.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid5x.rb | lib/bullet/mongoid5x.rb | # frozen_string_literal: true
module Bullet
module Mongoid
def self.enable
require 'mongoid'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_method :origin_eager_load,... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification_collector.rb | lib/bullet/notification_collector.rb | # frozen_string_literal: true
require 'set'
module Bullet
class NotificationCollector
attr_reader :collection
def initialize
reset
end
def reset
@collection = Set.new
end
def add(value)
@collection << value
end
def notifications_present?
!@collection.empty... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record61.rb | lib/bullet/active_record61.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record52.rb | lib/bullet/active_record52.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/registry.rb | lib/bullet/registry.rb | # frozen_string_literal: true
module Bullet
module Registry
autoload :Base, 'bullet/registry/base'
autoload :Object, 'bullet/registry/object'
autoload :Association, 'bullet/registry/association'
autoload :CallStack, 'bullet/registry/call_stack'
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/rack.rb | lib/bullet/rack.rb | # frozen_string_literal: true
require 'rack/request'
require 'json'
require 'cgi'
module Bullet
class Rack
include Dependency
NONCE_MATCHER = /(script|style)-src .*'nonce-(?<nonce>[A-Za-z0-9+\/]+={0,2})'/
def initialize(app)
@app = app
end
def call(env)
return @app.call(env) unles... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record71.rb | lib/bullet/active_record71.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record41.rb | lib/bullet/active_record41.rb | # frozen_string_literal: true
module Bullet
module ActiveRecord
def self.enable
require 'active_record'
::ActiveRecord::Base.class_eval do
class << self
alias_method :origin_find_by_sql, :find_by_sql
def find_by_sql(sql, binds = [])
result = origin_find_by_sql(... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record4.rb | lib/bullet/active_record4.rb | # frozen_string_literal: true
module Bullet
module ActiveRecord
def self.enable
require 'active_record'
::ActiveRecord::Base.class_eval do
class << self
alias_method :origin_find_by_sql, :find_by_sql
def find_by_sql(sql, binds = [])
result = origin_find_by_sql(... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/stack_trace_filter.rb | lib/bullet/stack_trace_filter.rb | # frozen_string_literal: true
require "bundler"
using Bullet::Ext::Object
module Bullet
module StackTraceFilter
VENDOR_PATH = '/vendor'
# @param bullet_key[String] - use this to get stored call stack from call_stacks object.
def caller_in_project(bullet_key = nil)
vendor_root = Bullet.app_root +... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid6x.rb | lib/bullet/mongoid6x.rb | # frozen_string_literal: true
module Bullet
module Mongoid
def self.enable
require 'mongoid'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_method :origin_eager_load,... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record60.rb | lib/bullet/active_record60.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/mongoid9x.rb | lib/bullet/mongoid9x.rb | # frozen_string_literal: true
module Bullet
module Mongoid
def self.enable
require 'mongoid'
require 'rubygems'
::Mongoid::Contextual::Mongo.class_eval do
alias_method :origin_first, :first
alias_method :origin_last, :last
alias_method :origin_each, :each
alias_m... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record5.rb | lib/bullet/active_record5.rb | # frozen_string_literal: true
module Bullet
module SaveWithBulletSupport
def _create_record(*)
super do
Bullet::Detector::NPlusOneQuery.update_inversed_object(self)
Bullet::Detector::NPlusOneQuery.add_impossible_object(self)
yield(self) if block_given?
end
end
end
mod... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector.rb | lib/bullet/detector.rb | # frozen_string_literal: true
module Bullet
module Detector
autoload :Base, 'bullet/detector/base'
autoload :Association, 'bullet/detector/association'
autoload :NPlusOneQuery, 'bullet/detector/n_plus_one_query'
autoload :UnusedEagerLoading, 'bullet/detector/unused_eager_loading'
autoload :Counte... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/active_record42.rb | lib/bullet/active_record42.rb | # frozen_string_literal: true
module Bullet
module ActiveRecord
def self.enable
require 'active_record'
::ActiveRecord::Base.class_eval do
class << self
alias_method :origin_find, :find
def find(*args)
result = origin_find(*args)
if Bullet.start?
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/dependency.rb | lib/bullet/dependency.rb | # frozen_string_literal: true
module Bullet
module Dependency
def mongoid?
@mongoid ||= defined?(::Mongoid)
end
def active_record?
@active_record ||= defined?(::ActiveRecord)
end
def active_record_version
@active_record_version ||=
begin
if active_record40?
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification.rb | lib/bullet/notification.rb | # frozen_string_literal: true
module Bullet
module Notification
autoload :Base, 'bullet/notification/base'
autoload :UnusedEagerLoading, 'bullet/notification/unused_eager_loading'
autoload :NPlusOneQuery, 'bullet/notification/n_plus_one_query'
autoload :CounterCache, 'bullet/notification/counter_cach... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector/counter_cache.rb | lib/bullet/detector/counter_cache.rb | # frozen_string_literal: true
using Bullet::Ext::Object
module Bullet
module Detector
class CounterCache < Base
class << self
def add_counter_cache(object, associations)
return unless Bullet.start?
return unless Bullet.counter_cache_enable?
return unless object.bullet... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector/n_plus_one_query.rb | lib/bullet/detector/n_plus_one_query.rb | # frozen_string_literal: true
using Bullet::Ext::Object
module Bullet
module Detector
class NPlusOneQuery < Association
extend Dependency
extend StackTraceFilter
class << self
# executed when object.associations is called.
# first, it keeps this method call for object.associat... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector/base.rb | lib/bullet/detector/base.rb | # frozen_string_literal: true
module Bullet
module Detector
class Base
end
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector/unused_eager_loading.rb | lib/bullet/detector/unused_eager_loading.rb | # frozen_string_literal: true
using Bullet::Ext::Object
using Bullet::Ext::String
module Bullet
module Detector
class UnusedEagerLoading < Association
extend Dependency
extend StackTraceFilter
class << self
# check if there are unused preload associations.
# get related_obje... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/detector/association.rb | lib/bullet/detector/association.rb | # frozen_string_literal: true
using Bullet::Ext::Object
module Bullet
module Detector
class Association < Base
class << self
def add_object_associations(object, associations)
return unless Bullet.start?
return if !Bullet.n_plus_one_query_enable? && !Bullet.unused_eager_loading_... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification/counter_cache.rb | lib/bullet/notification/counter_cache.rb | # frozen_string_literal: true
module Bullet
module Notification
class CounterCache < Base
def body
klazz_associations_str
end
def title
'Need Counter Cache with Active Record size'
end
end
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification/n_plus_one_query.rb | lib/bullet/notification/n_plus_one_query.rb | # frozen_string_literal: true
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
"#{klazz_associations_str}\n Add to your quer... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification/base.rb | lib/bullet/notification/base.rb | # frozen_string_literal: true
module Bullet
module Notification
class Base
attr_accessor :notifier, :url
attr_reader :base_class, :associations, :path
def initialize(base_class, association_or_associations, path = nil)
@base_class = base_class
@associations =
associat... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/notification/unused_eager_loading.rb | lib/bullet/notification/unused_eager_loading.rb | # frozen_string_literal: true
module Bullet
module Notification
class UnusedEagerLoading < Base
def initialize(callers, base_class, associations, path = nil)
super(base_class, associations, path)
@callers = callers
end
def body
"#{klazz_associations_str}\n Remove from... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/ext/string.rb | lib/bullet/ext/string.rb | # frozen_string_literal: true
module Bullet
module Ext
module String
refine ::String do
def bullet_class_name
last_colon = self.rindex(':')
last_colon ? self[0...last_colon].dup : self.dup
end
end
end
end
end
| ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/ext/object.rb | lib/bullet/ext/object.rb | # frozen_string_literal: true
module Bullet
module Ext
module Object
refine ::Object do
attr_writer :bullet_key, :bullet_primary_key_value
def bullet_key
return "#{self.class}:" if respond_to?(:persisted?) && !persisted?
@bullet_key ||= "#{self.class}:#{bullet_primary_... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/registry/base.rb | lib/bullet/registry/base.rb | # frozen_string_literal: true
module Bullet
module Registry
class Base
attr_reader :registry
def initialize
@registry = {}
end
def [](key)
@registry[key]
end
def each(&block)
@registry.each(&block)
end
def delete(base)
@registry.... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/registry/object.rb | lib/bullet/registry/object.rb | # frozen_string_literal: true
using Bullet::Ext::Object
using Bullet::Ext::String
module Bullet
module Registry
class Object < Base
def add(bullet_key)
super(bullet_key.bullet_class_name, bullet_key)
end
def include?(bullet_key)
super(bullet_key.bullet_class_name, bullet_key)
... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
flyerhzm/bullet | https://github.com/flyerhzm/bullet/blob/5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0/lib/bullet/registry/association.rb | lib/bullet/registry/association.rb | # frozen_string_literal: true
module Bullet
module Registry
class Association < Base
def merge(base, associations)
@registry.merge!(base => associations)
end
def similarly_associated(base, associations)
@registry.select { |key, value| key.include?(base) && value == associations... | ruby | MIT | 5f4173292a0566ca5ba0b1ff8e1d6362f3be85b0 | 2026-01-04T15:39:36.933591Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.