tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Include base controller helpers when possible

Open waj opened this issue 3 years ago • 0 comments

Motivation

In a Rails project is common to have helpers defined in a base controller. Currently those helpers are declared on every .rbi file for descendant controllers unless those controllers define new helpers. The problem with this approach is that whenever a slight change is made on the base controller helpers, most .rbi files for descendants get updated making reviews of PRs annoying.

Implementation

If the helpers module of a controller is the same helpers module of it superclass then it's guaranteed that the helpers methods are the same. So, instead of generating the helpers methods, use the helper methods module generated for the parent class.

Tests

There was already a test with the case I described, so I updated the test to check that the subclass module just includes the parent's class module.

waj avatar Dec 08 '22 14:12 waj