Sha256: ea03f40b6658504390f6ceab9cba0b2beca0e691789111804cb8a410fae3226c
Contents?: true
Size: 710 Bytes
Versions: 9
Compression:
Stored size: 710 Bytes
Contents
require 'timespan/mongoid/models/time_period' class Account include Mongoid::Document include Mongoid::Timespanned field :name field :period, :type => ::Timespan, :between => true timespan_methods :period embeds_one :time_period timespan_container_delegates :time_period, :dates, :all def self.create_it! duration, flex = nil acc = self.new period: ::Timespan.new(duration: duration), time_period: ::TimePeriod.new acc.time_period.dates_duration = 1.day acc.time_period.flex = flex if flex acc end # def to_s # %Q{ # name: #{name} # } # 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
9 entries across 9 versions & 1 rubygems