Project

lite_enum

0.0
No commit activity in last 3 years
No release in over 3 years
Lightweight Enum class
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

lite_enum version build

A short and sweet enumerator class for usage with ActiveRecord, most likely.

Goals:

  • Concise
  • Readable
  • Useful for DOBT's stack
  • Plain ol' Ruby API
  • No auto-generation of predicate methods like in ActiveRecord::Enum

Usage

# Gemfile
gem 'lite_enum'

# app/models/foo.rb
class Foo < ActiveRecord::Base
  def self.sizes
    LiteEnum.new(:small, :medium, :large)
  end
end

Foo.sizes[1] # => :small
Foo.sizes[:small] # => 1
foo = Foo.new(size: Foo.sizes[:small])
foo.size # => 1
foo.size == Foo.sizes[:small] # => true