Sha256: 2eea89c961bf8ebd02db8171a62788ce54a2943f0bbc15b460a0a58615e46c6c

Contents?: true

Size: 915 Bytes

Versions: 8

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Mongoid

  # Encapsulates behavior around logging and caching warnings so they are only
  # logged once.
  #
  # @api private
  module Warnings

    class << self
      def warning(id, message)
        singleton_class.class_eval do
          define_method("warn_#{id}") do
            unless instance_variable_get("@#{id}")
              Mongoid.logger.warn(message)
              instance_variable_set("@#{id}", true)
            end
          end
        end
      end
    end

    warning :geo_haystack_deprecated, 'The geoHaystack type is deprecated.'
    warning :as_json_compact_deprecated, '#as_json :compact option is deprecated. Please call #compact on the returned Hash object instead.'
    warning :symbol_type_deprecated, 'The BSON Symbol type is deprecated by MongoDB. Please use String or StringifiedSymbol field types instead of the Symbol field type'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-8.0.8 lib/mongoid/warnings.rb
mongoid-8.0.7 lib/mongoid/warnings.rb
mongoid-8.0.6 lib/mongoid/warnings.rb
mongoid-8.0.5 lib/mongoid/warnings.rb
mongoid-8.0.4 lib/mongoid/warnings.rb
mongoid-8.0.3 lib/mongoid/warnings.rb
mongoid-8.0.2 lib/mongoid/warnings.rb
mongoid-8.0.1 lib/mongoid/warnings.rb