Sha256: 7502cbfc005d3cb57be2cede77324281948c7675bad203ab93d90438a7afbf10

Contents?: true

Size: 434 Bytes

Versions: 3

Compression:

Stored size: 434 Bytes

Contents

# Sample spec class
class Event
  include Mongoid::Document
  include Mongoid::Geospatial

  field :name
  field :date, type: Date

  field :location, type: Point, delegate: true, default: [7, 7]

  def self.each_day(start_date, end_date)
    groups = only(:date).asc(:date)
             .where(:date.gte => start_date, :date.lte => end_date).group
    groups.each do |hash|
      yield(hash['date'], hash['group'])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-geospatial-5.0.0 spec/models/event.rb
mongoid-geospatial-4.0.1 spec/models/event.rb
mongoid-geospatial-4.0.0 spec/models/event.rb