Module: Risitor::Visitor::ClassMethods
- Defined in:
- lib/risitor/visitor.rb
Overview
List of the methods extended by a Visitor.
Instance Method Summary collapse
-
#add_visit_method(*types, &block) ⇒ Object
(also: #when_visiting)
Add/override a visit method for the types
types. -
#alias_visit_method(visit_method_alias) ⇒ Object
Alias the ‘visit` method.
-
#remove_visit_method(*types) ⇒ Object
Remove the visit methods for the types
types. -
#reset_visit_methods ⇒ Object
Remove all the visit methods.
-
#visit_methods ⇒ Object
Return a list of the visit method.
-
#visitable_types ⇒ Object
Return a list of the types with a visit method.
Instance Method Details
#add_visit_method(*types, &block) ⇒ Object Also known as: when_visiting
Add/override a visit method for the types types.
39 40 41 42 43 44 |
# File 'lib/risitor/visitor.rb', line 39 def add_visit_method(*types, &block) block = block.curry(1) if block.arity.zero? types.each do |type| specialized_add_visit_method(type, &block) end end |
#alias_visit_method(visit_method_alias) ⇒ Object
Alias the ‘visit` method.
34 35 36 |
# File 'lib/risitor/visitor.rb', line 34 def alias_visit_method(visit_method_alias) specialized_alias_visit_method(visit_method_alias) end |
#remove_visit_method(*types) ⇒ Object
Remove the visit methods for the types types.
47 48 49 50 51 |
# File 'lib/risitor/visitor.rb', line 47 def remove_visit_method(*types) types.each do |type| specialized_remove_visit_method(type) end end |
#reset_visit_methods ⇒ Object
Remove all the visit methods.
54 55 56 57 58 |
# File 'lib/risitor/visitor.rb', line 54 def reset_visit_methods visit_methods.each do |visit_method| specialized_remove_method(visit_method) end end |
#visit_methods ⇒ Object
Return a list of the visit method.
61 62 63 64 65 |
# File 'lib/risitor/visitor.rb', line 61 def visit_methods return methods.select do |method| VisitMethodHelper.match(method) end end |
#visitable_types ⇒ Object
Return a list of the types with a visit method.
68 69 70 71 72 |
# File 'lib/risitor/visitor.rb', line 68 def visitable_types return visit_methods.collect do |visit_method| VisitMethodHelper.get_type(visit_method) end end |