mongoid_geo 0.2.2 → 0.2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -144,11 +144,15 @@ nearest_positions = Position.geoNear(another_address.location, :pos, :mode => :s
144
144
 
145
145
  </pre>
146
146
 
147
- # if you need to operate on the Mongoid models referenced by the query result, simply call #to_models on it
148
- # Fx to get the city of the first model instance from the query result:
147
+ If you need to operate on the Mongoid models referenced by the query result, simply call #to_models on it
148
+ Fx to get the city of the first model instance from the query result:
149
149
 
150
150
  @nearest_city = Position.geoNear(another_address.location, :pos).to_models.first.city@
151
151
 
152
+ You can also use a #to_model method on an individual query result like this:
153
+
154
+ @nearest_city = Position.geoNear(another_address.location, :pos).first.to_model.city@
155
+
152
156
  h2. Mongoid Geo extra inclusions
153
157
 
154
158
  Find addresses near a point using spherical distance calculation
@@ -12,10 +12,16 @@ module Mongoid
12
12
  end
13
13
 
14
14
  module Models
15
+ # def to_models
16
+ # map do |m|
17
+ # m.to_model
18
+ # end
19
+ # end
20
+
15
21
  def to_models
16
- map do |m|
17
- m.to_model
18
- end
22
+ clazz = first.clazz
23
+ ids = map(&:_id)
24
+ clazz.where(:_id.in => ids).to_a
19
25
  end
20
26
  end
21
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &2153931280 !ruby/object:Gem::Requirement
17
+ requirement: &2154151040 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '2.4'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2153931280
25
+ version_requirements: *2154151040
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mongoid
28
- requirement: &2153930800 !ruby/object:Gem::Requirement
28
+ requirement: &2154150040 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.0.0.rc.6
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2153930800
36
+ version_requirements: *2154150040
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bson_ext
39
- requirement: &2153930340 !ruby/object:Gem::Requirement
39
+ requirement: &2154149000 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.1.6
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2153930340
47
+ version_requirements: *2154149000
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: active_support
50
- requirement: &2153929860 !ruby/object:Gem::Requirement
50
+ requirement: &2154148060 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 3.0.4
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2153929860
58
+ version_requirements: *2154148060
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: hashie
61
- requirement: &2153929280 !ruby/object:Gem::Requirement
61
+ requirement: &2154147040 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '1.0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2153929280
69
+ version_requirements: *2154147040
70
70
  description: Geo spatial extension on Mongoid 2, to add more geo-spatial capabilities
71
71
  email:
72
72
  - kmandrup@gmail.com