Class: PropelApi::ControllerGenerator
- Inherits:
-
NamedBase
- Object
- Rails::Generators::NamedBase
- NamedBase
- PropelApi::ControllerGenerator
- Defined in:
- lib/generators/propel_api/controller/controller_generator.rb
Instance Method Summary collapse
- #add_routes ⇒ Object
- #check_dependencies_before_destroy ⇒ Object
- #create_controller ⇒ Object
- #create_controller_test ⇒ Object
- #create_integration_test ⇒ Object
- #show_completion_message ⇒ Object
- #validate_model_exists ⇒ Object
Methods included from ConfigurationMethods
Instance Method Details
#add_routes ⇒ Object
88 89 90 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 88 def add_routes create_propel_routes end |
#check_dependencies_before_destroy ⇒ Object
79 80 81 82 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 79 def check_dependencies_before_destroy # Only check critical dependencies during destroy operations check_for_critical_dependencies if behavior == :revoke end |
#create_controller ⇒ Object
84 85 86 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 84 def create_controller create_propel_controller_template end |
#create_controller_test ⇒ Object
92 93 94 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 92 def create_controller_test create_propel_controller_test end |
#create_integration_test ⇒ Object
96 97 98 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 96 def create_integration_test create_propel_integration_test end |
#show_completion_message ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 100 def # Use shared completion message framework from Base class generated_files = [ "๐ฎ Controller: app/controllers/#{controller_path}/#{controller_file_name}.rb", "๐งช Controller Tests: test/controllers/#{controller_path}/#{controller_file_name}_test.rb", "๐งช Integration Tests: test/integration/#{file_name}_api_test.rb" ] next_steps = [ "Test your API: GET #{api_route_path}", "Run tests: rails test test/controllers/#{controller_path}/#{controller_file_name}_test.rb", "Run integration tests: rails test test/integration/#{file_name}_api_test.rb" ] if @adapter == 'propel_facets' next_steps << "Customize facets in: app/models/#{file_name}.rb" end ( resource_type: "Controller", generated_files: generated_files, next_steps: next_steps ) end |
#validate_model_exists ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/generators/propel_api/controller/controller_generator.rb', line 57 def validate_model_exists # Ensure attributes are parsed before validation parse_attributes_from_args # Only require model when auto-introspection is needed model_file_exists = File.exist?(File.join(destination_root, "app/models/#{file_name}.rb")) if should_auto_introspect? && !model_file_exists raise Thor::Error, "Model #{class_name} does not exist. Please create the model first or use 'rails generate propel_api #{class_name}' to create the complete resource." end # Show educational warning when no explicit choice is made if ![:all_attributes] && (@attributes.nil? || @attributes.empty?) && model_file_exists show_auto_introspection_warning end # Process polymorphic parent information if provided process_polymorphic_parents if [:parents].present? # Validate attributes if not using introspection validate_attributes_exist unless should_auto_introspect? end |