Sha256: 2e2e8a334e94776a745a5f38a36b10bda700e5a418ced9a2c0f90c92267646d2

Contents?: true

Size: 732 Bytes

Versions: 11

Compression:

Stored size: 732 Bytes

Contents

require 'active_enum/base'
require 'active_enum/extensions'
require 'active_enum/acts_as_enum'
require 'active_enum/version'

module ActiveEnum
  mattr_accessor :enum_classes
  self.enum_classes = []

  mattr_accessor :use_name_as_value
  self.use_name_as_value = false

  class Configuration
    def enum(name, &block)
      class_name = name.to_s.camelize
      class_def = <<-end_eval
        class #{class_name} < ActiveEnum::Base
        end
      end_eval
      eval(class_def, TOPLEVEL_BINDING)
      new_enum = Module.const_get(class_name)
      new_enum.class_eval(&block)
    end
  end

  def self.define(&block)
    raise "Define requires block" unless block_given?
    Configuration.new.instance_eval(&block)
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_enum-0.6.6 lib/active_enum.rb
active_enum-0.7.1 lib/active_enum.rb
active_enum-0.7.0 lib/active_enum.rb
active_enum-0.6.5 lib/active_enum.rb
active_enum-0.6.4 lib/active_enum.rb
active_enum-0.6.3 lib/active_enum.rb
active_enum-0.6.1 lib/active_enum.rb
active_enum-0.6.0 lib/active_enum.rb
active_enum-0.5.1 lib/active_enum.rb
active_enum-0.5.0 lib/active_enum.rb
active_enum-0.4.1 lib/active_enum.rb