module ActsAsTaggableOn::Utils
Public Class Methods
connection()
click to toggle source
Use ActsAsTaggableOn::Tag
connection
# File lib/acts_as_taggable_on/utils.rb, line 7 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 32 def escape_like(str) str.gsub(/[!%_]/) { |x| '!' + x } end
legacy_activerecord?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 27 def legacy_activerecord? ActiveRecord.version <= Gem::Version.new('5.3.0') end
like_operator()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 23 def like_operator using_postgresql? ? 'ILIKE' : 'LIKE' end
sha_prefix(string)
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 19 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 15 def using_mysql? connection && connection.adapter_name == 'Mysql2' end
using_postgresql?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 11 def using_postgresql? connection && connection.adapter_name == 'PostgreSQL' end