Class: SyntaxTree::BasicVisitor::VisitMethodsChecker
- Inherits:
-
Module
- Object
- Module
- SyntaxTree::BasicVisitor::VisitMethodsChecker
- Defined in:
- lib/syntax_tree/basic_visitor.rb
Overview
This module is responsible for checking all of the methods defined within a given block to ensure that they are valid visit methods.
Defined Under Namespace
Classes: Status
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
This is the status of the checker.
Instance Method Summary collapse
- #disable! ⇒ Object
-
#initialize ⇒ VisitMethodsChecker
constructor
A new instance of VisitMethodsChecker.
Constructor Details
#initialize ⇒ VisitMethodsChecker
Returns a new instance of VisitMethodsChecker.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/syntax_tree/basic_visitor.rb', line 53 def initialize # We need the status to be an instance variable so that it can be # accessed by the disable! method, but also a local variable so that it # can be captured by the define_method block. status = @status = Status.new(true) define_method(:method_added) do |name| BasicVisitor.visit_method(name) if status.checking super(name) end end |
Instance Attribute Details
#status ⇒ Object (readonly)
This is the status of the checker. It’s used to determine whether or not we should be checking the methods that are defined. It is kept as an instance variable so that it can be disabled later.
51 52 53 |
# File 'lib/syntax_tree/basic_visitor.rb', line 51 def status @status end |
Instance Method Details
#disable! ⇒ Object
65 66 67 |
# File 'lib/syntax_tree/basic_visitor.rb', line 65 def disable! status.checking = false end |