Class: Toro::Database
- Inherits:
-
Object
- Object
- Toro::Database
- Defined in:
- lib/toro/database.rb
Constant Summary collapse
- SQL_DIRECTORY =
Pathname.new(File.('sql', File.dirname(__FILE__)))
Class Method Summary collapse
- .connection ⇒ Object
- .down ⇒ Object
- .query(sql, parameters = []) ⇒ Object
- .raw_connection ⇒ Object
- .up ⇒ Object
- .with_connection(&block) ⇒ Object
Class Method Details
.connection ⇒ Object
16 17 18 |
# File 'lib/toro/database.rb', line 16 def connection ActiveRecord::Base.connection end |
.down ⇒ Object
11 12 13 14 |
# File 'lib/toro/database.rb', line 11 def down connection.disable_extension :hstore if ActiveRecord::VERSION::MAJOR >= 4 execute_file('down') end |
.query(sql, parameters = []) ⇒ Object
24 25 26 |
# File 'lib/toro/database.rb', line 24 def query(sql, parameters=[]) raw_connection.exec(sql, parameters) end |
.raw_connection ⇒ Object
20 21 22 |
# File 'lib/toro/database.rb', line 20 def raw_connection connection.raw_connection end |
.up ⇒ Object
6 7 8 9 |
# File 'lib/toro/database.rb', line 6 def up connection.enable_extension :hstore if ActiveRecord::VERSION::MAJOR >= 4 execute_file('up') end |
.with_connection(&block) ⇒ Object
28 29 30 |
# File 'lib/toro/database.rb', line 28 def with_connection(&block) ActiveRecord::Base.connection_pool.with_connection(&block) end |