blob: 0e33128f0133ecc8a3533d8c96687416d8f5f3a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module Psych
module Visitors
class Visitor
attr_reader :started, :finished
alias :finished? :finished
alias :started? :started
def initialize
@started = false
@finished = false
end
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
|