Module: Tsuga::Adapter::Mongoid::Cluster::ScopeMethods

Defined in:
lib/tsuga/adapter/mongoid/cluster.rb

Instance Method Summary collapse

Instance Method Details

#at_depth(depth) ⇒ Object



17
18
19
# File 'lib/tsuga/adapter/mongoid/cluster.rb', line 17

def at_depth(depth)
  where(:depth => depth)
end

#in_tile(*tiles) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
# File 'lib/tsuga/adapter/mongoid/cluster.rb', line 21

def in_tile(*tiles)
  # where(:geohash.gte => sw, :geohash.lte => ne)
  depths = tiles.map(&:depth).uniq
  raise ArgumentError, 'all tiles must be at same depth' if depths.length > 1
  where(:tilecode.in => tiles.map(&:prefix))
end