Sha256: 38fd617fe70c2f8e814366bade981bbf26c3916a58ef82ab2006126db1c3a204

Contents?: true

Size: 546 Bytes

Versions: 6

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

module Rails
  class DecoratorGenerator < Rails::Generators::NamedBase

    source_root File.expand_path("../templates", __FILE__)
    check_class_collision suffix: "Decorator"

    def copy_files
      path = File.join("app", "decorators", class_path, "#{file_name}_decorator.rb")
      template("decorator.rb.tt", path)
    end

    private

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

    def remove_possible_suffix(name)
      name.sub(/_?decorator$/i, "")
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lite-decorator-2.0.1 lib/generators/rails/decorator_generator.rb
lite-decorator-2.0.0 lib/generators/rails/decorator_generator.rb
lite-decorator-1.3.1 lib/generators/rails/decorator_generator.rb
lite-decorator-1.3.0 lib/generators/rails/decorator_generator.rb
lite-decorator-1.2.1 lib/generators/rails/decorator_generator.rb
lite-decorator-1.2.0 lib/generators/rails/decorator_generator.rb