A short and sweet enumerator class for usage with ActiveRecord, most likely.
- Concise
- Readable
- Useful for DOBT's stack
- Plain ol' Ruby API
- No auto-generation of predicate methods like in
ActiveRecord::Enum
# 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