lib/woodhouse/worker.rb in woodhouse-0.1.2 vs lib/woodhouse/worker.rb in woodhouse-0.1.5

- old
+ new

@@ -66,9 +66,21 @@ Woodhouse::MixinRegistry.register self end end end + def available_jobs + @available_jobs ||= public_instance_methods(false) + end + + def only_jobs(*jobs) + @available_jobs = jobs + end + + def exclude_jobs(*jobs) + @available_jobs -= jobs + end + # You can dispatch a job +baz+ on class +FooBar+ by calling FooBar.async_baz. def method_missing(method, *args, &block) if method.to_s =~ /^asynch?_(.*)/ if instance_methods(false).detect{|meth| meth.to_s == $1 } Woodhouse.dispatch(@worker_name, $1, args.first)