diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-12-22 16:42:50 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-12-22 16:42:50 -0800 |
commit | 8b1ae37254535ea1d8cacbae95d5870ed64bea3d (patch) | |
tree | 2ef43d296bbe5ae1afe7fe2d12a69202b750d6b0 /lib | |
parent | 07d75b2cc4723eb895a409a263c9ce4afb557241 (diff) | |
download | psych-8b1ae37254535ea1d8cacbae95d5870ed64bea3d.zip |
using recursive hash for cache misses
Diffstat (limited to 'lib')
-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 |