Module: Bullet

Defined in:
lib/bullet.rb,
lib/bullet/rack.rb,
lib/bullet/version.rb,
lib/bullet/detector.rb,
lib/bullet/registry.rb,
lib/bullet/notification.rb,
lib/bullet/detector/base.rb,
lib/bullet/registry/base.rb,
lib/bullet/active_record2.rb,
lib/bullet/active_record3.rb,
lib/bullet/registry/object.rb,
lib/bullet/detector/counter.rb,
lib/bullet/notification/base.rb,
lib/bullet/action_controller2.rb,
lib/bullet/detector/association.rb,
lib/bullet/registry/association.rb,
lib/bullet/notification_collector.rb,
lib/bullet/detector/n_plus_one_query.rb,
lib/bullet/notification/counter_cache.rb,
lib/bullet/notification/n_plus_one_query.rb,
lib/bullet/detector/unused_eager_association.rb,
lib/bullet/notification/unused_eager_loading.rb

Defined Under Namespace

Modules: ActiveRecord, Detector, Notification, Registry Classes: ActionController, BulletRailtie, NotificationCollector, Rack

Constant Summary collapse

DETECTORS =
[ Bullet::Detector::NPlusOneQuery,
Bullet::Detector::UnusedEagerAssociation,
Bullet::Detector::Counter ]
VERSION =
"2.0.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.disable_browser_cacheObject

Returns the value of attribute disable_browser_cache.



27
28
29
# File 'lib/bullet.rb', line 27

def disable_browser_cache
  @disable_browser_cache
end

.enableObject

Returns the value of attribute enable.



27
28
29
# File 'lib/bullet.rb', line 27

def enable
  @enable
end

.notification_collectorObject (readonly)

Returns the value of attribute notification_collector.



28
29
30
# File 'lib/bullet.rb', line 28

def notification_collector
  @notification_collector
end

Class Method Details

.bullet_logger=(active) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/bullet.rb', line 50

def bullet_logger=(active)
  if active
    bullet_log_file = File.open( 'log/bullet.log', 'a+' )
    bullet_log_file.sync
    UniformNotifier.customized_logger = bullet_log_file
  end
end

.clearObject



67
68
69
# File 'lib/bullet.rb', line 67

def clear
  DETECTORS.each {|bullet| bullet.clear}
end

.enable?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/bullet.rb', line 46

def enable?
  @enable == true
end

.end_requestObject



63
64
65
# File 'lib/bullet.rb', line 63

def end_request
  DETECTORS.each {|bullet| bullet.end_request}
end

.gather_inline_notificationsObject



80
81
82
83
84
85
86
# File 'lib/bullet.rb', line 80

def gather_inline_notifications
  responses = []
  for_each_active_notifier_with_notification do |notification|
    responses << notification.notify_inline
  end
  responses.join( "\n" )
end

.notification?Boolean

Returns:

  • (Boolean)


75
76
77
78
# File 'lib/bullet.rb', line 75

def notification?
  Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
  notification_collector.notifications_present?
end

.perform_out_of_channel_notificationsObject



88
89
90
91
92
# File 'lib/bullet.rb', line 88

def perform_out_of_channel_notifications
  for_each_active_notifier_with_notification do |notification|
    notification.notify_out_of_channel
  end
end

.start_requestObject



58
59
60
61
# File 'lib/bullet.rb', line 58

def start_request
  notification_collector.reset
  DETECTORS.each {|bullet| bullet.start_request}
end