Sha256: 13ae40c8e9526d3675d7548aa2ceaa423764bb517c5822107dcb89748c2d17a5

Contents?: true

Size: 871 Bytes

Versions: 43

Compression:

Stored size: 871 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 ] 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

43 entries across 39 versions & 4 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/relations/conversions.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/relations/conversions.rb
mongoid-5.2.1 lib/mongoid/relations/conversions.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/relations/conversions.rb
mongoid-6.1.0 lib/mongoid/relations/conversions.rb
mongoid-5.2.0 lib/mongoid/relations/conversions.rb
mongoid-5.2.0.rc0 lib/mongoid/relations/conversions.rb
mongoid-6.1.0.rc0 lib/mongoid/relations/conversions.rb
mongoid-6.0.3 lib/mongoid/relations/conversions.rb
mongoid-5.1.6 lib/mongoid/relations/conversions.rb
mongoid-6.0.2 lib/mongoid/relations/conversions.rb
mongoid-6.0.1 lib/mongoid/relations/conversions.rb
mongoid-5.1.5 lib/mongoid/relations/conversions.rb
mongoid-6.0.0 lib/mongoid/relations/conversions.rb
mongoid-5.1.4 lib/mongoid/relations/conversions.rb
mongoid-6.0.0.rc0 lib/mongoid/relations/conversions.rb
mongoid-6.0.0.beta lib/mongoid/relations/conversions.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/lib/mongoid/relations/conversions.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.3/lib/mongoid/relations/conversions.rb
mongoid-5.1.3 lib/mongoid/relations/conversions.rb