This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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