diff options
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 3604ba4..e317238 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -11,9 +11,9 @@ module Psych @st = {} @dispatch_cache = Hash.new do |h,klass| - method = klass.ancestors.map { |ancestor| - "visit_#{(ancestor.name || '').split('::').join('_')}" - }.find { |sig| respond_to? sig } + method = "visit_#{(klass.name || '').split('::').join('_')}" + + method = respond_to?(method) ? method : h[klass.superclass] raise(TypeError, "Can't dump #{target.class}") unless method |