Class: Alchemy::Generators::ModuleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/alchemy/module/module_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_templatesObject



23
24
25
26
27
# File 'lib/generators/alchemy/module/module_generator.rb', line 23

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

#initObject



12
13
14
15
16
17
# File 'lib/generators/alchemy/module/module_generator.rb', line 12

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

#make_routeObject



19
20
21
# File 'lib/generators/alchemy/module/module_generator.rb', line 19

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