33: def handle_asynchronously(method, opts = {})
34: aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1
35: with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"
36: define_method(with_method) do |*args|
37: curr_opts = opts.clone
38: curr_opts.each_key do |key|
39: if (val = curr_opts[key]).is_a?(Proc)
40: curr_opts[key] = if val.arity == 1
41: val.call(self)
42: else
43: val.call
44: end
45: end
46: end
47: delay(curr_opts).__send__(without_method, *args)
48: end
49: alias_method_chain method, :delay
50: end