Skip to content

A very light weight Rails plugin which let you filter ActiveRecord lists through `dm_get` method.

License

Notifications You must be signed in to change notification settings

denmarkmeralpis/dm_filter

Repository files navigation

Build Status Maintainability Test Coverage Gem Version

DmFilter

DmFilter is a very light weight Rails plugin that makes it easy to fetch your ActiveRecord lists using date or text as a parameter.

Installation

Add this line to your application's Gemfile:

gem 'dm_filter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dm_filter

include this into your model

include DmFilter

example

class Invoice < ApplicationRecord
    include DmFilter
end

Usage

Values for duration

  1. all (default)
  2. today
  3. yesterday
  4. this_week
  5. this_month
  6. last_month
  7. period

Available options

  1. duration(default is all)
  2. from(if day is equal to period)
  3. to(if day is equal to period)
  4. column_date (default is created_at)

Example

# specifying column_date
Invoice.dm_get(duration: 'today', column_date: 'paid_at')

or simply

# default column_date is created_at
Invoice.dm_get(duration: 'today')

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/dm_filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

A very light weight Rails plugin which let you filter ActiveRecord lists through `dm_get` method.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published