Class: Chewy::Type::Adapter::Mongoid

Inherits:
Orm show all
Defined in:
lib/chewy/type/adapter/mongoid.rb

Constant Summary

Constants inherited from Base

Base::BATCH_SIZE

Instance Attribute Summary

Attributes inherited from Orm

#default_scope

Attributes inherited from Base

#options, #target

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Orm

#import, #import_fields, #initialize, #load, #name

Methods inherited from Base

#import, #import_fields, #import_references, #load, #name, #type_name

Constructor Details

This class inherits a constructor from Chewy::Type::Adapter::Orm

Class Method Details

.accepts?(target) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/chewy/type/adapter/mongoid.rb', line 7

def self.accepts?(target)
  defined?(::Mongoid::Document) && (
    target.is_a?(Class) && target.ancestors.include?(::Mongoid::Document) ||
    target.is_a?(::Mongoid::Criteria))
end

Instance Method Details

#identify(collection) ⇒ Object



13
14
15
# File 'lib/chewy/type/adapter/mongoid.rb', line 13

def identify(collection)
  super(collection).map { |id| id.is_a?(BSON::ObjectId) ? id.to_s : id }
end