Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2011 22:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/1420383 to your computer and use it in GitHub Desktop.
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
index 6cddf6f..a992f4c 100644
--- a/lib/rexml/parsers/baseparser.rb
+++ b/lib/rexml/parsers/baseparser.rb
@@ -114,22 +114,10 @@ module REXML
def initialize( source )
self.stream = source
+ @listeners = []
end
def add_listener( listener )
- if !defined?(@listeners) or !@listeners
- @listeners = []
- instance_eval <<-EOL
- alias :_old_pull :pull
- def pull
- event = _old_pull
- @listeners.each do |listener|
- listener.receive event
- end
- event
- end
- EOL
- end
@listeners << listener
end
@@ -192,6 +180,14 @@ module REXML
# Returns the next event. This is a +PullEvent+ object.
def pull
+ _pull_inner.tap do |event|
+ @listeners.each do |listener|
+ listener.receive event
+ end
+ end
+ end
+
+ def _pull_inner
if @closed
x, @closed = @closed, nil
return [ :end_element, x ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment