From: Michael Ulm Date: 2006-02-21T16:42:51+09:00 Subject: Re: [QUIZ] metakoans.rb (#67) Awesome quiz! Here is my solution, quite ugly I'm afraid. Meta_value = {} def attribute(name, &block) (name.is_a?(Hash) ? name : {name => nil}).each do |key, value| define_method(key.to_sym) do if Meta_value[[self, key]].nil? Meta_value[[self, key]] = (block_given? ? instance_eval(&block) : value) else Meta_value[[self, key]] end end define_method((key + "=").to_sym) {|val| Meta_value[[self, key]] = val} define_method((key + "?").to_sym) {not Meta_value[[self, key]].nil?} end end -- Michael Ulm R&D Team ISIS Information Systems Austria tel: +43 2236 27551-219, fax: +43 2236 21081 e-mail: michael.ulm@isis-papyrus.com Visit our Website: www.isis-papyrus.com --------------------------------------------------------------- This e-mail is only intended for the recipient and not legally binding. Unauthorised use, publication, reproduction or disclosure of the content of this e-mail is not permitted. This email has been checked for known viruses, but ISIS accepts no responsibility for malicious or inappropriate content. ---------------------------------------------------------------