module ActsAsHoldable::DBUtils

Public Class Methods

connection() click to toggle source
# File lib/acts_as_holdable/db_utils.rb, line 6
def connection
  ActsAsHoldable::Holding.connection
end
escape_like(str) click to toggle source

escape _ and % characters in strings, since these are wildcards in SQL.

# File lib/acts_as_holdable/db_utils.rb, line 27
def escape_like(str)
  str.gsub(/[!%_]/) { |x| '!' + x }
end
like_operator() click to toggle source
# File lib/acts_as_holdable/db_utils.rb, line 22
def like_operator
  using_postgresql? ? 'ILIKE' : 'LIKE'
end
using_mysql?() click to toggle source
# File lib/acts_as_holdable/db_utils.rb, line 14
def using_mysql?
  connection && connection.adapter_name == 'Mysql2'
end
using_postgresql?() click to toggle source
# File lib/acts_as_holdable/db_utils.rb, line 10
def using_postgresql?
  connection && connection.adapter_name == 'PostgreSQL'
end
using_sqlite?() click to toggle source
# File lib/acts_as_holdable/db_utils.rb, line 18
def using_sqlite?
  connection && connection.adapter_name == 'SQLite'
end