Module: Ohm::Geoindex
- Defined in:
- lib/ohm/geoindex.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(model) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/ohm/geoindex.rb', line 7 def self.included(model) begin Ohm.redis.call!('GEOADD') rescue RuntimeError => e raise "This version of Redis (#{Ohm.redis.url}) does not support the geospatial API." if e. =~ /unknown command/ end model.extend(ClassMethods) end |
Instance Method Details
#delete ⇒ Object
27 28 29 30 |
# File 'lib/ohm/geoindex.rb', line 27 def delete redis.call('ZREM', self.class.key[:geoindex], self.id) super end |
#save ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ohm/geoindex.rb', line 17 def save super redis.queue('MULTI') redis.queue('ZREM', self.class.key[:geoindex], self.id) redis.queue('GEOADD', self.class.key[:geoindex], self.longitude, self.latitude, self.id) redis.queue('EXEC') redis.commit self end |