From: Tony Arcieri Date: 2011-01-26T02:33:34+09:00 Subject: Re: Surely there's a better way to do this... (implementing a DSL) --0016e6de01647f3b8a049aaf1c52 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jan 25, 2011 at 7:19 AM, Robert Klemme wrote: > First thing that strikes me odd is that you define methods on the > singleton class, i.e. instance methods of the newly created class. > What do you need a class for then - especially since your new class > inherits Object (which means, it does not inherit particular instance > functionality)? Because I'm building these classes for another API, namely Resque. I'm creating a DSL for building Resque jobs, which the documentation defines thusly: Resque jobs are Ruby classes (or modules) which respond to the perform method. Here's an example: class Archive @queue = :file_serve def self.perform(repo_id, branch = 'master') repo = Repository.find(repo_id) repo.create_archive(branch) end end So unfortunately I can't change the form of the classes I'm trying to generate (with the possible exception of changing them into modules) -- Tony Arcieri Medioh! Kudelski --0016e6de01647f3b8a049aaf1c52--