Module: Vernacular::AST::Modifiers::TypedMethodArgs::TypedMethodArgsRewriter
- Defined in:
- lib/vernacular/ast/modifiers/typed_method_args.rb
Overview
Methods to be included in the rewriter in order to handle ‘type_check_arg` nodes.
Instance Method Summary collapse
-
#on_def(node) ⇒ Object
Triggered whenever a ‘:def` node is added to the AST.
Instance Method Details
#on_def(node) ⇒ Object
Triggered whenever a ‘:def` node is added to the AST. Finds any `type_check_arg` nodes, replaces them with normal `:arg` nodes, and adds in the represented type check to the beginning of the method.
31 32 33 34 35 36 37 38 |
# File 'lib/vernacular/ast/modifiers/typed_method_args.rb', line 31 def on_def(node) type_checks = build_type_checks(node.children[1].children) if type_checks.any? insert_before(node.children[2].loc.expression, type_checks.join) end super end |