Sha256: e24593863c6f049d33090e791bf973779bf93cf507b3f8a7b0352bd86db0b18b

Contents?: true

Size: 385 Bytes

Versions: 2

Compression:

Stored size: 385 Bytes

Contents

require 'renum/enumerated_value'

module Renum
  module EnumeratedValueTypeFactory
    def create nest, type_name, values, &block
      klass = Class.new EnumeratedValue
      nest.const_set(type_name, klass)
      klass.class_eval &block if block_given?
      values.each do |name|
        klass.const_set(name, klass.new(name))
      end
    end
    module_function :create
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
renum-0.0.3 lib/renum/enumerated_value_type_factory.rb
renum-0.1.0 lib/renum/enumerated_value_type_factory.rb