Module: Eavi::Visitor::ModuleMethods

Defined in:
lib/eavi/visitor.rb

Overview

Extends if included or extended

Instance Method Summary collapse

Instance Method Details

#add_visit_method(*types, &block) ⇒ Object

Add/override a visit method for the types types.



53
54
55
56
57
58
# File 'lib/eavi/visitor.rb', line 53

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.



48
49
50
# File 'lib/eavi/visitor.rb', line 48

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.



61
62
63
64
65
# File 'lib/eavi/visitor.rb', line 61

def remove_visit_method(*types)
  types.each do |type|
    specialized_remove_visit_method(type)
  end
end

#reset_visit_methodsObject

Remove all the visit methods.



68
69
70
71
72
# File 'lib/eavi/visitor.rb', line 68

def reset_visit_methods
  visit_methods.each do |visit_method|
    specialized_remove_method(visit_method)
  end
end

#visit_methodsObject

Return a list of the visit method.



75
76
77
78
79
# File 'lib/eavi/visitor.rb', line 75

def visit_methods
  return methods.select do |method|
    VisitMethodHelper.match(method)
  end
end

#visitable_typesObject

Return a list of the types with a visit method.



82
83
84
85
86
# File 'lib/eavi/visitor.rb', line 82

def visitable_types
  return visit_methods.collect do |visit_method|
    VisitMethodHelper.get_type(visit_method)
  end
end