From: HIDAKA Takahiro Date: 2001-11-22T03:40:03+09:00 Subject: [ruby-talk:26056] FXRuby:: replacement to enum method. Hi, I'd like to propose replacement of enum method. module Responder # define class method klass.message_id(*syms) def Responder.append_features(klass) klass.instance_eval %{ def message_id(*syms) id = superclass::ID_LAST syms.each { |sym| const_set(sym, id) id += 1 } const_set(:ID_LAST, id) end } super end end This defines class method klass.message_id(*syms) when classes include Responder module. So, we can write like below. class MyWindow < FXMainWindow include Responder # define MyWindow::message_id method. message_id :ID_OPEN, :ID_SAVE # define constants MyWindow::ID_OPEN and ID_SAVE def initialize FXMAPFUNC(SEL_COMMAND, ID_OPEN, "onOpen") FXMAPFUNC(SEL_COMMAND, ID_SAVE, "onSave") FXMAPFUNC(SEL_UPDATE, ID_SAVE, "onUpdateSave") end end -- HIDAKA Takahiro