Module: Enumeration

Defined in:
lib/enumerations.rb

Overview

i want to be able to write DogType < Enumeration

enumerate_values :pekinezer, :bulldog, :jack_russell

enumerate_values :pekinezer => 'Jako lijepi pekinezer'

end

DogType.all => [DogType, DogType, DogType] DogType.find(id) => DogType

if something == DogType.pekinezer # => <#DogType> if something == DogType::Pekinezer # => <#DogType> # => TODO if something == DogType # => <#DogType> # => TODO

So we have

  • id (numeric). used in database

  • lookup method (for comparison), symbol basically, used in source code

  • name. used in user interface

Status.draft? Status.review_pending?

TODO

Defined Under Namespace

Modules: ClassMethods Classes: Base

Class Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



28
29
30
# File 'lib/enumerations.rb', line 28

def self.included(receiver)
  receiver.extend ClassMethods
end