Skip to content

Commit

Permalink
Refactor generator
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirano55 committed Apr 8, 2018
1 parent ff72062 commit 9dedeb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/generators/active_admin_role/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ module Generators
class InstallGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
include ActiveAdminRole::Generators::Helper

source_root File.expand_path("../templates", __FILE__)

source_root File.expand_path("./templates", __dir__)
class_option :model, optional: true,
type: :string,
banner: "model",
Expand All @@ -20,7 +18,6 @@ def copy_initializer_file
end

def configure_model
generate :"active_admin:install #{model_class_name}" unless model_class_name.safe_constantize
inject_into_model
end

Expand All @@ -46,12 +43,12 @@ def configure_active_admin
"config.authorization_adapter = ActiveAdmin::CanCanAdapter"
end

def copy_admin_permission_file
template "admin/permission.tt", "app/admin/permission.rb"
def copy_admin_permissions_file
template "admin/permissions.tt", "app/admin/permissions.rb"
end

def configure_admin_user_file
inject_into_file "app/admin/#{model_file_path}.rb",
def configure_admin_users_file
inject_into_file "app/admin/#{model_class_name.tableize}.rb",
" role_changeable\n",
after: "ActiveAdmin.register #{model_class_name} do\n"
end
Expand Down

0 comments on commit 9dedeb3

Please sign in to comment.