10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/mongo_mapper/extensions/array.rb', line 10
def to_mongo(value, options = {})
stringify_bson = options[:stringify_bson]
recursive = options[:recursive]
value = value.clone if recursive
value = value.respond_to?(:lines) ? value.lines : value
value = value.to_a
value.map! do |v|
case v
when Document, EmbeddedDocument, Hash, Array, Set
v = v.to_mongo(options) if v and recursive
when BSON::ObjectId, BSON::Binary
v = v.to_s if stringify_bson
end
v
end
value
end
|