@@ -12,22 +12,19 @@ module ActiveRecordReplica
1212 # In a non-Rails environment, supply the environment such as
1313 # 'development', 'production'
1414 def self . install! ( adapter_class = nil , environment = nil )
15- replica_config =
16- if ActiveRecord ::Base . connection . respond_to? ( :config )
17- ActiveRecord ::Base . connection . config [ :replica ]
18- else
19- ActiveRecord ::Base . configurations [ environment || Rails . env ] [ 'replica' ]
20- end
21- if replica_config
22- ActiveRecord ::Base . logger . info "ActiveRecordReplica.install! v#{ ActiveRecordReplica ::VERSION } Establishing connection to replica database"
23- Replica . establish_connection ( replica_config )
24-
25- # Inject a new #select method into the ActiveRecord Database adapter
26- base = adapter_class || ActiveRecord ::Base . connection . class
27- base . include ( Extensions )
28- else
29- ActiveRecord ::Base . logger . info "ActiveRecordReplica not installed since no replica database defined"
15+ replica_config = ActiveRecord ::Base . configurations [ environment || Rails . env ] [ "replica" ]
16+ unless replica_config
17+ ActiveRecord ::Base . logger . info ( "ActiveRecordReplica not installed since no replica database defined" )
18+ return
3019 end
20+
21+ version = ActiveRecordReplica ::VERSION
22+ ActiveRecord ::Base . logger . info ( "ActiveRecordReplica.install! v#{ version } Establishing connection to replica database" )
23+ Replica . establish_connection ( replica_config )
24+
25+ # Inject a new #select method into the ActiveRecord Database adapter
26+ base = adapter_class || ActiveRecord ::Base . connection . class
27+ base . include ( Extensions )
3128 end
3229
3330 # Force reads for the supplied block to read from the primary database
0 commit comments