Sha256: 983da0a5e1504cd316a49b6e6f019688ae39cf2be091ef580f0e49a9b3c08aa9

Contents?: true

Size: 544 Bytes

Versions: 3

Compression:

Stored size: 544 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators'

module Rails
  class FormGenerator < Rails::Generators::NamedBase

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

    def copy_files
      path = File.join('app', 'forms', class_path, "#{file_name}_form.rb")
      template('form.rb.tt', path)
    end

    private

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

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lite-form-1.1.0 lib/generators/rails/form_generator.rb
lite-form-1.0.5 lib/generators/rails/form_generator.rb
lite-form-1.0.4 lib/generators/rails/form_generator.rb