module ActsAsTaggableOn::Utils
Public Instance Methods
active_record42?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 48 def active_record42? active_record4? && ::ActiveRecord::VERSION::MINOR >= 2 end
active_record4?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 44 def active_record4? ::ActiveRecord::VERSION::MAJOR == 4 end
connection()
click to toggle source
Use ActsAsTaggableOn::Tag connection
# File lib/acts_as_taggable_on/utils.rb, line 5 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 57 def escape_like(str) str.gsub(/[!%_]/) { |x| '!' + x } end
like_operator()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 52 def like_operator using_postgresql? ? 'ILIKE' : 'LIKE' end
postgresql_support_json?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 19 def postgresql_support_json? postgresql_version >= 9.2 end
postgresql_version()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 13 def postgresql_version if using_postgresql? connection.execute('SHOW SERVER_VERSION').first['server_version'].to_f end end
sha_prefix(string)
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 40 def sha_prefix(string) Digest::SHA1.hexdigest("#{string}#{rand}")[0..6] end
supports_concurrency?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 36 def supports_concurrency? !using_sqlite? end
using_case_insensitive_collation?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 32 def using_case_insensitive_collation? using_mysql? && connection.collation =~ /_ci\Z/ end
using_mysql?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 27 def using_mysql? #We should probably use regex for mysql to support prehistoric adapters connection && connection.adapter_name == 'Mysql2' end
using_postgresql?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 9 def using_postgresql? connection && connection.adapter_name == 'PostgreSQL' end
using_sqlite?()
click to toggle source
# File lib/acts_as_taggable_on/utils.rb, line 23 def using_sqlite? connection && connection.adapter_name == 'SQLite' end