module Bullet

def active_presenters

def active_presenters
  PRESENTERS.select { |presenter| presenter.send :active? }
end

def bullet_logger=(bullet_logger)

def bullet_logger=(bullet_logger)
  Bullet::Presenter::BulletLogger.setup if bullet_logger
end

def clear

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

def enable=(enable)

def enable=(enable)
  @enable = enable
  if enable? 
    Bullet::ActiveRecord.enable
    if Rails.version =~ /^2./
      Bullet::ActionController.enable
    end
  end
end

def enable?

def enable?
  @enable == true
end

def end_request

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

def for_each_active_presenter_with_notification

def for_each_active_presenter_with_notification
  active_presenters.each do |presenter|
    @notification_collector.collection.each do |notification|
      notification.presenter = presenter
      yield notification
    end
  end
end

def gather_inline_notifications

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

def growl=(growl)

def growl=(growl)
  Bullet::Presenter::Growl.setup_connection( self.growl_password ) if growl
end

def notification?

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

def perform_out_of_channel_notifications

def perform_out_of_channel_notifications
  for_each_active_presenter_with_notification do |notification|
    notification.present_out_of_channel
  end
end

def start_request

def start_request
  @notification_collector ||= Bullet::NotificationCollector.new
  @notification_collector.reset
  DETECTORS.each {|bullet| bullet.start_request}
end

def xmpp=(xmpp)

def xmpp=(xmpp)
  Bullet::Presenter::Xmpp.setup_connection( xmpp ) if xmpp
end