Sha256: 2aba7a3ff1508858739822b5c302f25b928022809d32fe9f300ff193821757f8

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Rails
  class CommandGenerator < Rails::Generators::NamedBase

    source_root File.expand_path('../templates', __FILE__)
    check_class_collision suffix: 'Command'

    def copy_files
      path = File.join('app', 'commands', class_path, "#{file_name}_command.rb")
      empty_directory('app/commands')
      template('command.rb.tt', path)
    end

    private

    def file_name
      @_file_name ||= remove_possible_suffix(super)
    end

    def remove_possible_suffix(name)
      name.sub(/_?command$/i, '')
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lite-command-1.0.9 lib/generators/rails/command_generator.rb