Skip to content

Fix method redefined warning for support_email#1214

Merged
excid3 merged 1 commit intopay-rails:mainfrom
joemasilotti:fix-support-email-warning
Dec 23, 2025
Merged

Fix method redefined warning for support_email#1214
excid3 merged 1 commit intopay-rails:mainfrom
joemasilotti:fix-support-email-warning

Conversation

@joemasilotti
Copy link
Contributor

Pull Request

Summary:
Fix Ruby's "method redefined" warning.

Related Issue:
N/A

Description:
mattr_accessor :support_email creates a support_email= writer, but we immediately redefine it to add Mail::Address casting. This triggers Ruby's "method redefined" warning when running with warnings enabled.

Use mattr_reader instead since we define the writer manually.

Testing:

# Before (with mattr_accessor)
$ ruby -w -e "require 'pay'"
warning: method redefined; discarding old support_email=
# After (with mattr_reader)
$ ruby -w -e "require 'pay'"
# No warning

Checklist:

  • Code follows the project's coding standards
  • Tests have been added or updated to cover the changes
  • Documentation has been updated (if applicable)
  • All existing tests pass
  • Conforms to the contributing guidelines

Additional Notes:
One-line change. No functional difference, support_email getter and setter work identically.

`mattr_accessor :support_email` creates a `support_email=` writer, but
we immediately redefine it to add Mail::Address casting. This triggers
Ruby's "method redefined" warning when running with warnings enabled.

Use `mattr_reader` instead since we define the writer manually.
@excid3 excid3 merged commit 776a2a1 into pay-rails:main Dec 23, 2025
46 checks passed
@joemasilotti joemasilotti deleted the fix-support-email-warning branch December 23, 2025 18:01
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