Module: ZOMG::IDL::Visitable
- Included in:
- Nodes::Node
- Defined in:
- lib/zomg/idl/visitable.rb
Instance Method Summary collapse
-
#accept(visitor, &block) ⇒ Object
Based off the visitor pattern from RubyGarden.
Instance Method Details
#accept(visitor, &block) ⇒ Object
Based off the visitor pattern from RubyGarden
5 6 7 8 9 10 11 12 |
# File 'lib/zomg/idl/visitable.rb', line 5 def accept(visitor, &block) klass = self.class method_name = :"visit_#{klass.name.split(/::/).last}" unless visitor.respond_to?(method_name) raise "No visitor for #{self.class}" end visitor.send(method_name, self, &block) end |