Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 775 Bytes

README.md

File metadata and controls

35 lines (27 loc) · 775 Bytes

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