ign-mongo_mapper 0.8.6.1 → 0.8.6.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module MongoMapper
|
|
6
6
|
attr_reader :type, :name, :options, :query_options
|
7
7
|
|
8
8
|
# Options that should not be considered MongoDB query options/criteria
|
9
|
-
AssociationOptions = [:as, :class, :class_name, :dependent, :extend, :foreign_key, :in, :polymorphic]
|
9
|
+
AssociationOptions = [:as, :class, :class_name, :dependent, :extend, :foreign_key, :in, :polymorphic, :preserve_order]
|
10
10
|
|
11
11
|
def initialize(type, name, options={}, &extension)
|
12
12
|
@type, @name, @options, @query_options, @original_options = type, name, {}, {}, options
|
@@ -22,21 +22,21 @@ module MongoMapper
|
|
22
22
|
|
23
23
|
return [] if ids.blank?
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
if options[:preserve_order]
|
28
|
-
|
25
|
+
# IGN: preserve order if association.options[:preserve_order]
|
26
|
+
default_results = query(options).all
|
27
|
+
if association.options[:preserve_order]
|
28
|
+
ordered_results = Array.new
|
29
29
|
criteria[:_id].each do |id|
|
30
|
-
|
31
|
-
if
|
32
|
-
|
30
|
+
default_results.each do |element|
|
31
|
+
if id.eql?(element._id)
|
32
|
+
ordered_results << element
|
33
33
|
break
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
ordered_results
|
38
38
|
else
|
39
|
-
|
39
|
+
default_results
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
data/lib/mongo_mapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ign-mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
9
|
- 6
|
10
|
-
-
|
11
|
-
version: 0.8.6.
|
10
|
+
- 2
|
11
|
+
version: 0.8.6.2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- John Nunemaker
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-01-
|
21
|
+
date: 2011-01-28 00:00:00 -08:00
|
22
22
|
default_executable: mmconsole
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|