lib/ahoy.rb in ahoy_matey-1.4.1 vs lib/ahoy.rb in ahoy_matey-1.4.2
- old
+ new
@@ -1,5 +1,6 @@
+require "active_support"
require "active_support/core_ext"
require "addressable/uri"
require "browser"
require "geocoder"
require "referer-parser"
@@ -26,11 +27,11 @@
require "ahoy/stores/fluentd_store"
require "ahoy/stores/mongoid_store"
require "ahoy/stores/kafka_store"
require "ahoy/stores/kinesis_firehose_store"
require "ahoy/stores/bunny_store"
-require "ahoy/engine"
+require "ahoy/engine" if defined?(Rails)
require "ahoy/warden" if defined?(Warden)
# background jobs
begin
require "active_job"
@@ -104,21 +105,23 @@
mattr_accessor :track_bots
self.track_bots = false
end
-ActionController::Base.send :include, Ahoy::Controller
-ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord)
+if defined?(Rails)
+ ActionController::Base.send :include, Ahoy::Controller
+ ActiveRecord::Base.send(:extend, Ahoy::Model) if defined?(ActiveRecord)
-# ensure logger silence will not be added by activerecord-session_store
-# otherwise, we get SystemStackError: stack level too deep
-begin
- require "active_record/session_store/extension/logger_silencer"
-rescue LoadError
- require "ahoy/logger_silencer"
- Logger.send :include, Ahoy::LoggerSilencer
-
+ # ensure logger silence will not be added by activerecord-session_store
+ # otherwise, we get SystemStackError: stack level too deep
begin
- require "syslog/logger"
- Syslog::Logger.send :include, Ahoy::LoggerSilencer
- rescue LoadError; end
+ require "active_record/session_store/extension/logger_silencer"
+ rescue LoadError
+ require "ahoy/logger_silencer"
+ Logger.send :include, Ahoy::LoggerSilencer
+
+ begin
+ require "syslog/logger"
+ Syslog::Logger.send :include, Ahoy::LoggerSilencer
+ rescue LoadError; end
+ end
end