lib/blather/client/dsl.rb in blather-0.8.5 vs lib/blather/client/dsl.rb in blather-0.8.6

- old
+ new

@@ -83,12 +83,15 @@ module DSL autoload :PubSub, File.expand_path(File.join(File.dirname(__FILE__), *%w[dsl pubsub])) def self.append_features(o) + # Generate a method for every stanza handler that exists. Blather::Stanza.handler_list.each do |handler_name| - o.__send__ :remove_method, handler_name if !o.is_a?(Class) && o.method_defined?(handler_name) + o.__send__ :define_method, handler_name do |*args, &callback| + handle handler_name, *args, &callback + end end super end # The actual client connection @@ -304,17 +307,8 @@ r.to = s.from r.id = s.id client.write r end client.write client.caps.c - end - - # Generate a method for every stanza handler that exists. - Blather::Stanza.handler_list.each do |handler_name| - module_eval <<-METHOD, __FILE__, __LINE__ - def #{handler_name}(*args, &callback) - handle :#{handler_name}, *args, &callback - end - METHOD end end # DSL end # Blather