module ActsAsTaggableOn::Utils
Public Class Methods
connection()
click to toggle source
Use ActsAsTaggableOn::Tag
connection
# File lib/acts-as-taggable-on/utils.rb, line 9 def connection ActsAsTaggableOn::Tag.connection end
escape_like(str)
click to toggle source
escape _ and % characters in strings, since these are wildcards in SQL.
# File lib/acts-as-taggable-on/utils.rb, line 30 def escape_like(str) str.gsub(/[!%_]/) { |x| "!#{x}" } end
like_operator()
click to toggle source
# File lib/acts-as-taggable-on/utils.rb, line 25 def like_operator using_postgresql? ? 'ILIKE' : 'LIKE' end
sha_prefix(string)
click to toggle source
# File lib/acts-as-taggable-on/utils.rb, line 21 def sha_prefix(string) Digest::SHA1.hexdigest(string)[0..6] end
using_mysql?()
click to toggle source
# File lib/acts-as-taggable-on/utils.rb, line 17 def using_mysql? connection && connection.adapter_name == 'Mysql2' end
using_postgresql?()
click to toggle source
# File lib/acts-as-taggable-on/utils.rb, line 13 def using_postgresql? connection && %w[PostgreSQL PostGIS].include?(connection.adapter_name) end