Module: Hibiki::Rails::Generators::MultiselectInjections

Included in:
MultiselectGenerator
Defined in:
lib/generators/hibiki/rails/multiselect_injections.rb

Overview

What hibiki:rails:multiselect writes into files the app already owns. Every injection is guarded by a wired? probe, so a re-run is a no-op, and every missing anchor downgrades to a manual_wiring notice rather than a half-edit.

Constant Summary collapse

CHANNEL_ANCHOR =

The anchors, all text the scaffold templates emit verbatim. Thor's insert_into_file replaces EVERY match, so each anchor must occur exactly once in its file — never a bare "

", which the row form closes two blocks with.

"  include Hibiki::Rails::Channel\n"
ERB_FIELDSET_CLOSE =

The fieldset's close: the one "

" a blank line follows (the form-actions close runs straight into the ERB end, and a boolean field's wrap closes at four spaces, which a bare-string anchor matched as a substring).

%r{^  </div>\n\n}
FORM_ANCHOR =

The whole reactive_attributes statement, continuation lines included: minimal lines up to the first blank one.

/^[ \t]*reactive_attributes\b(?:.*\n)+?\n/
PHLEX_FIELDSET_CLOSE =
"      end\n\n      form_actions"
ROW_ACTIONS_ANCHOR_ERB =

Line-anchored for the same reason: a boolean field guards its toggle with the same text two spaces deeper.

/^ {4}<% if actions %>/
ROW_ACTIONS_ANCHOR_PHLEX =
"    row_actions if @actions"