Class: Redmine::Generators::ProjectModuleGenerator

Inherits:
Rails::Generators::ModelGenerator
  • Object
show all
Includes:
PluginNameAttribute
Defined in:
lib/redmine/generators/project_module_generator.rb

Instance Method Summary collapse

Methods included from PluginNameAttribute

#initialize

Instance Method Details

#add_project_moduleObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/redmine/generators/project_module_generator.rb', line 11

def add_project_module
  pm = "  project_module :#{plural_table_name} do\n"
  pm << "    permission :view_#{plural_table_name}, #{plural_table_name}: [:index, :show]\n"
  pm << "    permission :manage_#{plural_table_name}, #{plural_table_name}: [:new, :create, :edit, :update, :destroy]\n"
  pm << "  end\n"

  sentinel = /Redmine::Plugin\.register\s+:\w+\s+do\s?\n/

  in_root do
    inject_into_file "init.rb", pm, after: sentinel
  end
end