Module: TrilogyAdapter::Connection
- Defined in:
- lib/trilogy_adapter/connection.rb
Overview
Necessary for enhancing ActiveRecord to recognize the Trilogy adapter. Example:
ActiveRecord::Base.public_send :extend, TrilogyAdapter::Connection
This will allow downstream applications to use the Trilogy adapter. Example:
ActiveRecord::Base.establish_connection adapter: "trilogy",
host: "localhost",
database: "demo_development"
Instance Method Summary collapse
Instance Method Details
#trilogy_adapter_class ⇒ Object
17 18 19 |
# File 'lib/trilogy_adapter/connection.rb', line 17 def trilogy_adapter_class ActiveRecord::ConnectionAdapters::TrilogyAdapter end |
#trilogy_connection(config) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/trilogy_adapter/connection.rb', line 21 def trilogy_connection(config) configuration = config.dup # Set FOUND_ROWS capability on the connection so UPDATE queries returns number of rows # matched rather than number of rows updated. configuration[:found_rows] = true = [ configuration[:host], configuration[:port], configuration[:database], configuration[:username], configuration[:password], configuration[:socket], 0 ] trilogy_adapter_class.new nil, logger, , configuration end |