Sha256: 1b442515e86fdf414b66f3ea20acf1e7eab73ec63ace59009c8fe53704ad558c
Contents?: true
Size: 816 Bytes
Versions: 1
Compression:
Stored size: 816 Bytes
Contents
# # ActiveRecord read from a slave # module ActiveRecordSlave # Install ActiveRecord::Slave into ActiveRecord to redirect reads to the slave # By default, only the default Database adapter (ActiveRecord::Base.connection.class) # is extended with slave read capabilities def self.install!(adapter_class = nil) if slave_config = ActiveRecord::Base.connection.config[:slave] Rails.logger.info "ActiveRecordSlave.install! v#{ActiveRecordSlave::VERSION} Establishing connection to slave database" Slave.establish_connection(slave_config) # Inject a new #select method into the ActiveRecord Database adapter base = adapter_class || ActiveRecord::Base.connection.class base.send(:include, InstanceMethods) base.alias_method_chain :select, :slave_reader end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record_slave-0.1.0 | lib/active_record_slave/active_record_slave.rb |