Sha256: 8331c6141e4cf214dca575c7bf3e17e27806c4c1be0318ff71fc8bcecf3a26ff
Contents?: true
Size: 940 Bytes
Versions: 7
Compression:
Stored size: 940 Bytes
Contents
# frozen_string_literal: true require "rails/generators" class StimulusReflexGenerator < Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) argument :name, type: :string, required: true, banner: "NAME" argument :actions, type: :array, default: [], banner: "action action" class_options skip_stimulus: false, skip_app_reflex: false, skip_reflex: false, skip_app_controller: false def execute actions.map!(&:underscore) copy_application_files if behavior == :invoke template "app/reflexes/%file_name%_reflex.rb" unless options[:skip_reflex] template "app/javascript/controllers/%file_name%_controller.js" unless options[:skip_stimulus] end private def copy_application_files template "app/reflexes/application_reflex.rb" unless options[:skip_app_reflex] template "app/javascript/controllers/application_controller.js" unless options[:skip_app_controller] end end
Version data entries
7 entries across 7 versions & 1 rubygems