Skip to content

Check constant exists instead of rescuing#53

Merged
ewhorton merged 2 commits intomainfrom
fix-rubocop-issues
Aug 15, 2025
Merged

Check constant exists instead of rescuing#53
ewhorton merged 2 commits intomainfrom
fix-rubocop-issues

Conversation

@ewhorton
Copy link
Contributor

This pull request refactors the logic for creating record classes in lib/rulezilla/dsl.rb to improve code organization and readability. The main change is breaking up the monolithic create_klass method into smaller, single-responsibility methods. This makes the code easier to maintain and understand, while also refining how support modules are included.

Refactoring and code organization:

  • Split the create_klass method into three distinct methods: create_record_class, setup_record_class, and define_record_methods, each handling a specific part of the record class creation process.
  • Updated the inclusion of support modules to use a safer conditional check (Object.const_defined?) before including, preventing unnecessary exceptions if the module does not exist.

Visibility and method encapsulation:

  • Added the new helper methods (create_record_class, setup_record_class, define_record_methods) to the list of private class methods, ensuring proper encapsulation and restricting their access to internal use only.

@simplybusiness/palm-trees

@ewhorton ewhorton requested a review from a team as a code owner August 15, 2025 12:42
@ewhorton
Copy link
Contributor Author

/dobby version patch

@ewhorton ewhorton merged commit 529917c into main Aug 15, 2025
5 of 6 checks passed
@ewhorton ewhorton deleted the fix-rubocop-issues branch August 15, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants