Sha256: 2e213015ba0ca8d532f26d446bf42bfc55982dcb387ab90a706cd058666c2049

Contents?: true

Size: 658 Bytes

Versions: 6

Compression:

Stored size: 658 Bytes

Contents

require 'degu/renum/enumerated_value_type_factory'

module Degu
  # 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 renum(type_name, values = :defined_in_block, &block)
      nest = self.is_a?(Module) ? self : Object
      EnumeratedValueTypeFactory.create(nest, type_name, values, &block)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
degu-0.9.0 lib/degu/renum.rb
degu-0.8.1 lib/degu/renum.rb
degu-0.8.0 lib/degu/renum.rb
degu-0.7.0 lib/degu/renum.rb
degu-0.6.0 lib/degu/renum.rb
degu-0.5.0 lib/degu/renum.rb