Sha256: f8beaa2bbfa05080a44905287f1993260e3543ac55db24361f6c077d4939e904

Contents?: true

Size: 880 Bytes

Versions: 15

Compression:

Stored size: 880 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Relations

    # Contains utility methods for object id conversion.
    module Conversions
      extend self

      # Mark the provided object as unconvertable to bson or not, and always
      # return the provided object.
      #
      # @example Flag the object.
      #   Conversions.flag(metadata, 15)
      #
      # @param [ Object ] object The object to flag.
      # @param [ Metadata ] metadata The relation metadata.
      #
      # @return [ Object ] The provided object.
      #
      # @since 2.3.0
      def flag(object, metadata)
        inverse = metadata.inverse_klass
        if inverse.using_object_ids? || object.is_a?(BSON::ObjectId)
          object
        else
          if object.is_a?(String)
            object.unconvertable_to_bson = true
          end
          object
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
mongoid-6.4.8 lib/mongoid/relations/conversions.rb
mongoid-6.4.7 lib/mongoid/relations/conversions.rb
mongoid-6.4.5 lib/mongoid/relations/conversions.rb
mongoid-5.4.1 lib/mongoid/relations/conversions.rb
mongoid-6.4.4 lib/mongoid/relations/conversions.rb
mongoid-6.4.2 lib/mongoid/relations/conversions.rb
mongoid-6.4.1 lib/mongoid/relations/conversions.rb
mongoid-5.4.0 lib/mongoid/relations/conversions.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/relations/conversions.rb
mongoid-6.4.0 lib/mongoid/relations/conversions.rb
mongoid-6.3.0 lib/mongoid/relations/conversions.rb
mongoid-6.2.1 lib/mongoid/relations/conversions.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/lib/mongoid/relations/conversions.rb
mongoid-6.2.0 lib/mongoid/relations/conversions.rb
mongoid-6.1.1 lib/mongoid/relations/conversions.rb