Sha256: 8a9730a2e05a8b53f3d424c79ddd32fd07efdac06e8c352d723fef244919c24e

Contents?: true

Size: 932 Bytes

Versions: 3

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

# This module is deprecated and will be removed in the incoming versions

module ActsAsTaggableOn
  module Utils
    class << self
      # Use ActsAsTaggableOn::Tag connection
      def connection
        ActsAsTaggableOn::Tag.connection
      end

      def using_postgresql?
        connection && %w[PostgreSQL PostGIS].include?(connection.adapter_name)
      end

      def using_mysql?
        connection && connection.adapter_name == 'Mysql2'
      end

      def sha_prefix(string)
        Digest::SHA1.hexdigest(string)[0..6]
      end

      def like_operator
        using_postgresql? ? 'ILIKE' : 'LIKE'
      end

      def legacy_activerecord?
        ActiveRecord.version <= Gem::Version.new('5.3.0')
      end

      # escape _ and % characters in strings, since these are wildcards in SQL.
      def escape_like(str)
        str.gsub(/[!%_]/) { |x| "!#{x}" }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/acts-as-taggable-on-9.0.1/lib/acts_as_taggable_on/utils.rb
acts-as-taggable-on-9.0.1 lib/acts_as_taggable_on/utils.rb
acts-as-taggable-on-9.0.0 lib/acts_as_taggable_on/utils.rb