Sha256: aebdbf11031c6ea9c74b39f638e1df36cdf1040caf07af09f0fa406c0525a726

Contents?: true

Size: 416 Bytes

Versions: 1

Compression:

Stored size: 416 Bytes

Contents

class Account
  include Mongoid::Document
  include Mongoid::Timespanned

  field :period, :type => ::Timespan, :between => true

  delegate :start_date, to: :period

  timespan_setters :period

  def self.create_it! duration
    t = ::Timespan.new(duration: duration)
    self.new period: t
  end

  def self.between from, to
    Account.where(:'period.from'.gt => from.to_i, :'period.to'.lte => to.to_i)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timespan-0.4.2 spec/timespan/mongoid/models/account_3x.rb