Module: Eavi::Visitor::MethodsWhenIncludedAndExtended
- Defined in:
- lib/eavi/visitor.rb
Overview
Extends if included or extended
Instance Method Summary collapse
-
#add_visit_method(*types, &block) ⇒ Object
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
Returns a list of the visit method.
-
#visitable_types ⇒ Object
Returns a list of the types with a visit method.
Instance Method Details
#add_visit_method(*types, &block) ⇒ Object
Add/override a visit method for the types types.
63 64 65 66 67 68 69 70 71 |
# File 'lib/eavi/visitor.rb', line 63 def add_visit_method(*types, &block) if block.arity.zero? original_block = block block = proc { |_| instance_exec(&original_block) } end types.each do |type| specialized_add_visit_method(type, block) end end |
#alias_visit_method(visit_method_alias) ⇒ Object
Alias the ‘visit` method.
58 59 60 |
# File 'lib/eavi/visitor.rb', line 58 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.
74 75 76 77 78 |
# File 'lib/eavi/visitor.rb', line 74 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.
81 82 83 84 85 |
# File 'lib/eavi/visitor.rb', line 81 def reset_visit_methods visit_methods.each do |visit_method| specialized_remove_method(visit_method) end end |
#visit_methods ⇒ Object
Returns a list of the visit method.
88 89 90 |
# File 'lib/eavi/visitor.rb', line 88 def visit_methods specialized_visit_methods end |
#visitable_types ⇒ Object
Returns a list of the types with a visit method.
93 94 95 96 97 |
# File 'lib/eavi/visitor.rb', line 93 def visitable_types return visit_methods.collect do |visit_method| VisitMethodHelper.get_type(visit_method) end end |