Class: Tasker::Generators::AuthorizationCoordinatorGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Tasker::Generators::AuthorizationCoordinatorGenerator
- Defined in:
- lib/generators/tasker/authorization_coordinator_generator.rb
Overview
Rails generator for creating authorization coordinators
This generator creates authorization coordinator classes that inherit from Tasker::Authorization::BaseCoordinator and implement the authorization interface for different scenarios.
Instance Method Summary collapse
-
#create_coordinator_class ⇒ Object
Generate the authorization coordinator class.
-
#create_spec_file ⇒ Object
Generate the spec file if requested.
-
#print_instructions ⇒ Object
Print usage instructions.
Instance Method Details
#create_coordinator_class ⇒ Object
Generate the authorization coordinator class
38 39 40 41 42 43 44 |
# File 'lib/generators/tasker/authorization_coordinator_generator.rb', line 38 def create_coordinator_class @coordinator_class_name = coordinator_class_name @user_class_name = user_class_name template 'authorization_coordinator.rb.erb', File.join([:directory], "#{file_name}_coordinator.rb") end |
#create_spec_file ⇒ Object
Generate the spec file if requested
47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/tasker/authorization_coordinator_generator.rb', line 47 def create_spec_file return unless [:with_spec] @coordinator_class_name = coordinator_class_name @user_class_name = user_class_name template 'authorization_coordinator_spec.rb.erb', File.join('spec', [:directory].sub('app/', ''), "#{file_name}_coordinator_spec.rb") end |
#print_instructions ⇒ Object
Print usage instructions
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/generators/tasker/authorization_coordinator_generator.rb', line 58 def print_instructions say "\n#{set_color('Authorization Coordinator Generated!', :green)}" say set_color('=' * 50, :green) say "\nGenerated files:" say " #{set_color("#{[:directory]}/#{file_name}_coordinator.rb", :cyan)} - Coordinator class" if [:with_spec] say " #{set_color("spec/#{[:directory].sub('app/', '')}/#{file_name}_coordinator_spec.rb", :cyan)} - Test file" end say "\nNext steps:" say '1. Configure Tasker to use your coordinator:' say coordinator_configuration_example say "\n2. Ensure your User model includes the Authorizable concern:" say user_model_example say "\n3. Customize the authorization logic in your coordinator" say "\n4. Run the tests to verify everything works:" say " #{set_color( "bundle exec rspec spec/#{[:directory].sub('app/', '')}/#{file_name}_coordinator_spec.rb", :yellow )}" say "\nFor more information, see the Tasker authentication guide:" say " #{set_color('docs/AUTH.md', :cyan)}" end |