Sha256: 383cb38fd964a10f18e0b048a17c78d1d5c1ad7fcf691b4efb9beb91c53c8bdb

Contents?: true

Size: 878 Bytes

Versions: 33

Compression:

Stored size: 878 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?(Moped::BSON::ObjectId)
          object
        else
          if object.is_a?(String)
            object.unconvertable_to_bson = true
          end
          object
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 4 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/relations/conversions.rb
mongoid-3.1.6 lib/mongoid/relations/conversions.rb
mongoid-3.1.5 lib/mongoid/relations/conversions.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/relations/conversions.rb
mongoid_rails4-4.0.0 lib/mongoid/relations/conversions.rb
mongoid-3.1.4 lib/mongoid/relations/conversions.rb
mongoid-3.1.3 lib/mongoid/relations/conversions.rb
mongoid-3.1.2 lib/mongoid/relations/conversions.rb
mongoid-3.0.23 lib/mongoid/relations/conversions.rb
mongoid-3.1.1 lib/mongoid/relations/conversions.rb
mongoid-3.1.0 lib/mongoid/relations/conversions.rb
mongoid-3.0.22 lib/mongoid/relations/conversions.rb
mongoid-3.0.21 lib/mongoid/relations/conversions.rb
mongoid-3.0.20 lib/mongoid/relations/conversions.rb
mongoid-3.0.19 lib/mongoid/relations/conversions.rb
mongoid-3.0.18 lib/mongoid/relations/conversions.rb
mongoid-3.0.17 lib/mongoid/relations/conversions.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/relations/conversions.rb
mongoid-3.0.16 lib/mongoid/relations/conversions.rb
mongoid-3.0.15 lib/mongoid/relations/conversions.rb