Sha256: 940684496e0bf29a13f12195481390bc26cdb1d16f616ab1a68c4e6f57ad1a0f

Contents?: true

Size: 961 Bytes

Versions: 21

Compression:

Stored size: 961 Bytes

Contents

require 'rails'

module Alchemy
  module Generators
    class ModuleGenerator < ::Rails::Generators::Base
      desc "This generator generates an Alchemy module for you."
      argument :module_name, banner: "your_module_name"
      source_root File.expand_path('templates', File.dirname(__FILE__))

      def init
        @module_name = module_name.downcase
        @class_name = @module_name.singularize.classify
        @controller_name = @module_name.tableize
        @controller_class = @controller_name.classify.pluralize
      end

      def make_route
        route "namespace :admin do\n    resources :#{@controller_name}\n  end"
      end

      def copy_templates
        template "controller.rb.tt", "app/controllers/admin/#{@controller_name}_controller.rb"
        template "ability.rb.tt", "app/models/#{@module_name}_ability.rb"
        template "module_config.rb.tt", "config/initializers/alchemy_#{@module_name}.rb"
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
alchemy_cms-4.0.6 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.7 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.6 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.5 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.4 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.3 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.5 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.2 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.4 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.3 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.2 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.0.rc2 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.0.rc1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.1 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-4.0.0.beta lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.6.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.5.0 lib/rails/generators/alchemy/module/module_generator.rb
alchemy_cms-3.4.2 lib/rails/generators/alchemy/module/module_generator.rb