Module: Renum

Defined in:
lib/renum.rb,
lib/renum/name_serializer.rb,
lib/renum/enumerated_value.rb,
lib/renum/index_serializer.rb,
lib/renum/enumerated_value_type_factory.rb

Overview

Requiring 'renum' mixes the Renum module into both the main Object and Module, so it can be called from anywhere that you might reasonably define an enumeration with an implicit receiver.

Defined Under Namespace

Modules: EnumeratedValueTypeFactory Classes: EnumeratedValue, IndexSerializer, NameSerializer

Instance Method Summary (collapse)

Instance Method Details

- (Object) enum(type_name, values = :defined_in_block, &block)

Declares an enumerated type. If called inside a module, the enumerated type class will be nested inside that module.



17
18
19
20
# File 'lib/renum.rb', line 17

def enum type_name, values = :defined_in_block, &block
  nest = self.is_a?(Module) ? self : Object
  EnumeratedValueTypeFactory.create(nest, type_name, values, &block)
end