Class: RBI::Rewriters::NestSingletonMethods
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/rewriters/nest_singleton_methods.rb
Instance Method Summary collapse
Methods inherited from Visitor
Instance Method Details
#visit(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rbi/rewriters/nest_singleton_methods.rb', line 10 def visit(node) return unless node case node when Tree singleton_class = SingletonClass.new node.nodes.dup.each do |child| visit(child) next unless child.is_a?(Method) && child.is_singleton child.detach child.is_singleton = false singleton_class << child end node << singleton_class unless singleton_class.empty? end end |