Sha256: 36a1ba420b1697c4aba671dbb87595237663156c3d82c74cb0c3b62f8cd1e130

Contents?: true

Size: 1.13 KB

Versions: 40

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true
require "rails"

module Alchemy
  module Generators
    class IngredientGenerator < ::Rails::Generators::Base
      desc "This generator generates an Alchemy ingredient class for you."
      argument :class_name, banner: "ingredient_class_name"
      source_root File.expand_path("templates", __dir__)

      def init
        @class_name = class_name.classify
        @ingredients_view_path = "app/views/alchemy/ingredients"
      end

      def create_model
        template "model.rb.tt", "app/models/alchemy/ingredients/#{file_name}.rb"
      end

      def copy_templates
        @ingredient_editor_local = "#{file_name}_editor"
        @ingredient_view_local = "#{file_name}_view"
        template "view.html.erb", "#{@ingredients_view_path}/_#{file_name}_view.html.erb"
        template "editor.html.erb", "#{@ingredients_view_path}/_#{file_name}_editor.html.erb"
      end

      def show_todo
        say "\nPlease check the generated files and alter them to fit your needs."
      end

      private

      def file_name
        @_file_name ||= @class_name.classify.demodulize.underscore
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.9 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.8 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.7 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.6 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.5 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.14 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.4 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-7.0.0.pre.a lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.13 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.3 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.2 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.1 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.1.0 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.12 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.11 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.10 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.9 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.8 lib/generators/alchemy/ingredient/ingredient_generator.rb
alchemy_cms-6.0.7 lib/generators/alchemy/ingredient/ingredient_generator.rb