Sha256: 19a86594dd082a7c9eb6621e8808be49f7701b8c919ca7d9ffdcab5cb7c60e59

Contents?: true

Size: 1.6 KB

Versions: 21

Compression:

Stored size: 1.6 KB

Contents

require 'active_support/deprecation'

module ArJdbc

  # @private
  AR40 = ::ActiveRecord::VERSION::MAJOR > 3
  # @private
  AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
  # @private
  AR50 = ::ActiveRecord::VERSION::MAJOR > 4

  class << self

    # @private Internal API
    def warn_unsupported_adapter(adapter, version = nil)
      warn_prefix = 'NOTE:'
      if version # e.g. [4, 2]
        ar_version = [ ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR, ActiveRecord::VERSION::TINY ]
        if ( ar_version <=> version ) >= 0 # e.g. 4.2.0 > 4.2
          warn_prefix = "NOTE: ActiveRecord #{version.join('.')} with"
        else
          warn_prefix = nil
        end
      end
      warn "#{warn_prefix} adapter: #{adapter} is not (yet) fully supported by AR-JDBC," <<
      " please consider helping us out." if warn_prefix
    end

    def warn(message, once = nil)
      super(message) || true if warn?(message, once)
    end

    def deprecate(message, once = nil) # adds a "DEPRECATION WARNING: " prefix
      ::ActiveSupport::Deprecation.warn(message, caller_locations) || true if warn?(message, once)
    end

    private

    @@warns = nil
    @@warns = false if ENV_JAVA['arjdbc.warn'].eql? 'false'

    def warn?(message, once)
      return nil if @@warns.equal?(false) || ! message
      warns = @@warns ||= ( require 'set'; Set.new )
      return false if warns.include?(message)
      warns << message.dup if once
      true
    end

  end

  require 'arjdbc/jdbc/adapter'

  if ENV_JAVA['arjdbc.extensions.discover'].eql? 'true'
    self.discover_extensions
  else
    require 'arjdbc/discover'
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
activerecord-jdbc-alt-adapter-50.3.4-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-51.3.4-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-50.3.3-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-51.3.3-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-51.4-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-50.4-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-50.3.2-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-51.3.2-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-51.3.1-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-51.3.0-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-50.3.1-java lib/arjdbc/jdbc.rb
activerecord-jdbc-alt-adapter-50.3.0-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-51.3-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-50.3-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-52.1-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-51.2-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-50.2-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-52.0-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-51.1-java lib/arjdbc/jdbc.rb
activerecord-jdbc-adapter-50.1-java lib/arjdbc/jdbc.rb