Skip to content

A short and sweet enumerator class for usage with ActiveRecord.

Notifications You must be signed in to change notification settings

dobtco/lite_enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A short and sweet enumerator class for usage with ActiveRecord.

Resources

Stars

Watchers

Forks

Packages

No packages published