diff options
Diffstat (limited to 'jni/ruby/ext/psych/lib/psych/visitors/visitor.rb')
-rw-r--r-- | jni/ruby/ext/psych/lib/psych/visitors/visitor.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb b/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb new file mode 100644 index 0000000..4d7772f --- /dev/null +++ b/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb @@ -0,0 +1,19 @@ +module Psych + module Visitors + class Visitor + def accept target + visit target + end + + private + + DISPATCH = Hash.new do |hash, klass| + hash[klass] = "visit_#{klass.name.gsub('::', '_')}" + end + + def visit target + send DISPATCH[target.class], target + end + end + end +end |