Sha256: aa7025e8aa4eccd6f697ac7d6d6cf0411cc1ea43debc7ee793ec7e839a689e00

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

$:.unshift File.dirname(__FILE__)
require 'renum/enumerated_value_type_factory'

# 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.
module Renum

  # Figures out whether the new enumeration will live in Object or the 
  # receiving Module, then delegates to EnumeratedValueTypeFactory#create for 
  # all the real work.
  def enum type_name, values = :defined_in_block, &block
    nest = self.is_a?(Module) ? self : Object
    EnumeratedValueTypeFactory.create(nest, type_name, values, &block)
  end
end

extend Renum

Module.module_eval do
  include Renum
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renum-1.2.0 lib/renum.rb