spec/timespan/mongoid/account.rb in timespan-0.2.8 vs spec/timespan/mongoid/account.rb in timespan-0.3.1

- old
+ new

@@ -1,10 +1,14 @@ class Account - include Mongoid::Document - field :period, :type => TimeSpan + include Mongoid::Document + field :period, :type => TimeSpan, :between => true def self.create_it! duration s = self.new s.period = {duration: duration} s + end + + def self.between from, to + Account.where(:'period.from'.gt => from.to_i, :'period.to'.lte => to.to_i) end end