module ActsAsTaggableOn::Utils::OverallMethods

Public Instance Methods

sha_prefix(string) click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 18
def sha_prefix(string)
  Digest::SHA1.hexdigest("#{string}#{rand}")[0..6]
end
using_postgresql?() click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 10
def using_postgresql?
  ::ActiveRecord::Base.connection && ::ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
end
using_sqlite?() click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 14
def using_sqlite?
  ::ActiveRecord::Base.connection && ::ActiveRecord::Base.connection.adapter_name == 'SQLite'
end

Private Instance Methods

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 28
def escape_like(str)
  str.gsub(/[!%_]/){ |x| '!' + x }
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