Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kyanny
Forked from anonymous/dynamic_worker_class.rb
Created January 23, 2012 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyanny/1662122 to your computer and use it in GitHub Desktop.
Save kyanny/1662122 to your computer and use it in GitHub Desktop.
module Foo
module_eval do
host_name = `hostname`.chomp
host_name_short = `hostname -s`.chomp
queue_name = "#{host_name}"
# mod = Module.new
# mod.module_eval %Q{
# @queue = :abc #host_name
# def self.perform
# puts self.class.to_s
# end
# }
mod = Module.new do |submod|
@queue = queue_name
def submod.perform
puts self.class.to_s
end
end
module_name = host_name_short.sub(/^\w/){ |s| s.upcase }
const_set(module_name, mod)
end
end
require 'yaml'
require 'resque'
Foo.constants.each do |sym|
if const = Foo.const_get(sym)
Resque.enqueue(const)
end
end
# `resque-web`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment