summaryrefslogtreecommitdiff
path: root/test/ripper/dummyparser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ripper/dummyparser.rb')
-rw-r--r--test/ripper/dummyparser.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
index 2c107b37c2..cf0b5d2a30 100644
--- a/test/ripper/dummyparser.rb
+++ b/test/ripper/dummyparser.rb
@@ -47,13 +47,6 @@ class NodeList
end
class DummyParser < Ripper
- Ripper::PARSER_EVENTS.each do |event|
- event = event.to_s
- define_method(:"on_#{event}") do |*args|
- Node.new(event, *args)
- end
- end
-
def hook(name)
class << self; self; end.class_eval do
define_method(name) do |*a, &b|
@@ -188,4 +181,10 @@ class DummyParser < Ripper
def on_assoclist_from_args(a)
Node.new('assocs', *a.list)
end
+
+ (Ripper::PARSER_EVENTS.map(&:to_s) - instance_methods(false).map {|n|n.to_s.sub(/^on_/, '')}).each do |event|
+ define_method(:"on_#{event}") do |*args|
+ Node.new(event, *args)
+ end
+ end
end