No commit activity in last 3 years
No release in over 3 years
Heavily inspired by DDH's ActiveRecord::Enum, this little library is there to help you cut down the cruft in your models and make the world a happier place at the same time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 4.0.3
>= 0
~> 2.14

Runtime

~> 6.0
 Project Readme

Mongoid::Enum

Installation

Add this to your Gemfile:

gem "kumolus-mongoid-enum"

And then run bundle install.

Usage

class Payment
  include Mongoid::Document
  include Mongoid::Enum

  enum :status, [:pending, :approved, :declined]
end

Aaaaaaand then you get things like:

payment = Payment.create

payment.status
# => :pending

payment.approved!
# => :approved

payment.pending?
# => :false

Payment.approved
# => Mongoid::Criteria for payments with status == :approved