README.md in season-0.2 vs README.md in season-0.3

- old
+ new

@@ -24,49 +24,62 @@ In this first version Season only supports ActiveRecord, but we plan to also support Mongoid in a very short period of time. ## Usage -To use Season scopes just append `_before`, `_after` or `_between` to your datetime column names and pass the arguments accordingly. See this: +To use Season scopes just append `_before`, `_after` or `_between` to your date/datetime/timestamp column names and pass the arguments accordingly. See this: First, include Season in your model(s): ```ruby class User < ActiveRecord::Base include Season ... end ``` +### Scopes + Now, considering that our `User` class has three datetime columns named `:created_at`, `:updated_at` and `:confirmed_at`, the following scopes will be automatically available: ```ruby # * Time/DateTime/String instances are allowed as arguments. User.created_at_before(Time.now) User.created_at_after(DateTime.now) User.created_at_between(Time.now - 1.week, '31-01-2015') +# => [ActiveRecord::Relation of Users] User.updated_at_before(DateTime.now) User.updated_at_after('01-01-2015') User.updated_at_between(Time.now - 1.week, Time.now) +# => [ActiveRecord::Relation of Users] User.confirmed_at_before('01-01-2015') User.confirmed_at_after(DateTime.now) User.confirmed_at_between(Time.now - 1.year, Time.now - 1.week) +# => [ActiveRecord::Relation of Users] ``` They are chainable, so you can also do things like this: ```ruby User.where(id: [1, 2, 3]).created_before(Time.now) User.updated_after('01-01-2015').order(created_at: :asc) ``` +### Instance methods + +Other than scopes, useful instance methos will also be available: +```ruby +joe = User.first + +joe.created_at_before?(Time.now) +joe.updated_at_after?('10-10-2000') +joe.confirmed_at_between?('20-10-2013', DateTime.now) +# => true or false +``` + ## To Do -- Even more tests -- Support other ORMs (Mongoid, 'insert-more-here') -- Add Error Handling -- Add helpers for instances (like `User.first.created_before?('01-02-2015')`) -- Add support for queries with joins +- Support other ORMs (Mongoid, ...?) ## Contributing 1. Fork it ( https://github.com/joaodiogocosta/season/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`)