Module: PrimaryKeyFactory
- Defined in:
- lib/yodel/models/core/mongo/primary_key_factory.rb
Class Method Summary collapse
-
.create_pk(doc) ⇒ Object
The default mongo primary key factory (BSON::ObjectId) creates ids with symbol keys.
- .pk ⇒ Object
Class Method Details
.create_pk(doc) ⇒ Object
The default mongo primary key factory (BSON::ObjectId) creates ids with symbol keys. Yodel uses string keys (since records are retrieved with string keys) so Yodel mongo collections use this pk factory instead.
5 6 7 |
# File 'lib/yodel/models/core/mongo/primary_key_factory.rb', line 5 def self.create_pk(doc) doc.has_key?('_id') ? doc : doc.merge!('_id' => self.pk) end |