Closed zverok closed 3 years ago
🙇🏻♂️ Thanks so much for the PR! This is definitely something that hasn't been considered before, so this is a very welcome addition to the gem. Some initial thoughts:
/reports/monthly
routes with no paths (like monthly_performance_report_path
, as an example), hitting /reports/monthly
would only use one of the sets of defaults. We should annotate just a single line with the set of defaults that Rails will use if there are multiple "overrides," so to speak.format
in the defaults is okay, unless there are explicit situations where something like .json
is absolutely necessary for it to work.@nshki I fixed CC's offenses (though I must say that line length 80 seems a bit too limiting for Ruby, especially for inline blocks), plese take a look. PS: Probably it might make sense to set up rubocop the same way the CC set (I checked code with Rubocop, saw it had some offenses previously...)
Route may be declared with
defaults: {some: param}
, which is necessary information to understand how it is called in this case. Some examples (from real codebase, with slightly changed route names for anonymization):case 1: "by id" vs "all"
Now, controller method events has this annotation:
...which requires digging deep in code to understand how in "all" case it would understand it is
all
(or looking intoroutes.rb
, which Chusaku helps to avoid). With proposed addon:case 2: this or that
Annotations:
case 2: many of them!
Annotations:
WDYT?..
One concern with this idea is
defaults:
frequently used to passdefaults: {format: "json"}
or something like that, which current solution renders as any other default variable, but maybe it could be done smarter (by attaching.json
to path?..)