Class: ActionSentinel::AccessPermissionGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/action_sentinel/access_permission_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



17
18
19
# File 'lib/generators/action_sentinel/access_permission_generator.rb', line 17

def self.next_migration_number(path)
  ActiveRecord::Generators::Base.next_migration_number(path)
end

Instance Method Details

#create_access_pemission_and_migrationObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/action_sentinel/access_permission_generator.rb', line 21

def create_access_pemission_and_migration
  model_file = File.join("app", "models", "#{singular_model_name}.rb")

  if File.exist?(model_file) || revoke_process?
    inject_action_permissible_into_model(model_file)
    generate_access_permission
    generate_migration
  else
    logger.info("The file #{model_file} does not appear to exist")
  end
end