Sha256: b5451b365163cc6b8eab65239c10f41a46f49e277639ba5098e78c751270ecdf

Contents?: true

Size: 701 Bytes

Versions: 24

Compression:

Stored size: 701 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"

  def execute
    actions.map!(&:underscore)

    copy_application_files if behavior == :invoke

    template "app/reflexes/%file_name%_reflex.rb"
    template "app/javascript/controllers/%file_name%_controller.js"
  end

  private

  def copy_application_files
    template "app/reflexes/application_reflex.rb"
    template "app/javascript/controllers/application_controller.js"
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
stimulus_reflex-3.4.2 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.5.0.pre2 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.5.0.pre1 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.5.0.pre0 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.1 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre9 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre8 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre7 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre6 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre5 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre4 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre3 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre2 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre1 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.4.0.pre0 lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
stimulus_reflex-3.3.0 lib/generators/stimulus_reflex_generator.rb
stimulus_reflex-3.3.0.pre6 lib/generators/stimulus_reflex_generator.rb
stimulus_reflex-3.3.0.pre5 lib/generators/stimulus_reflex_generator.rb
stimulus_reflex-3.3.0.pre4 lib/generators/stimulus_reflex_generator.rb