README.md in timespan-0.4.2 vs README.md in timespan-0.4.3
- old
+ new
@@ -114,22 +114,39 @@
```ruby
require 'timespan/mongoid'
class Account
include Mongoid::Document
+ include Mongoid::Timespanned
+
field :period, :type => TimeSpan
+
+ timespan_methods :period
end
```
+`Mongoid::Timespanned` adds the following class level macros:
+
+* `timespan_methods name`
+* `timespan_delegates name`
+* `timespan_setters name`
+
Usage example:
```ruby
account = Account.create :period => {:duration => '2 days', :from => Date.today }
account.period.start_date
account.period.end_date
account.period.days
account.period.duration # => Duration
+
+account.period_start = tomorrow
+account.period_end = 5.days.from_now
+
+account.start_date == tomorrow
+account.end_date == tomorrow
+```
## Searching periods
```ruby
Account.where(:'period.from'.lt => 6.days.ago.to_i)