Refactor global DEBUG_ENABLED to module-based configuration #220
+31
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the handling of the DEBUG_ENABLED flag in the RSpec::OpenAPI project. Previously managed as a global variable, this refactor introduces a more encapsulated and controlled approach.
Motivation
The motivation behind this change is to improve code quality by increasing modularity and reducing global state.
Changes
Introduction of Config Class: Created a Config class within the RSpec::OpenAPI module to manage configuration settings, including the DEBUG_ENABLED flag.
Module-based Configuration Access: Shifted the access of the debug configuration to be through RSpec::OpenAPI::Config.debug_enabled, making its use more explicit and restricted to the module's context.
Environment Settings Loader: Added load_environment_settings method to the Config class to initialize configuration based on environment variables. This method is called conditionally when the OPENAPI environment variable is set.