Skip to content

Suppress method-redefined warnings in generated Ruby SDK models#23

Merged
mridang merged 3 commits intomainfrom
fix-redeclaration-warnings
Apr 22, 2025
Merged

Suppress method-redefined warnings in generated Ruby SDK models#23
mridang merged 3 commits intomainfrom
fix-redeclaration-warnings

Conversation

@mridang
Copy link
Copy Markdown
Collaborator

@mridang mridang commented Apr 22, 2025

Suppress method-redefined warnings in generated Ruby SDK models

Which Problems Are Solved

  • Generated model classes define both attr_accessor :field and a custom def field=(…) setter, leading Ruby to emit noisy
    warning: method redefined; discarding old field= messages.
  • These warnings clutter test output and obscure real failures.

How the Problems Are Solved

  • Introduce the warning gem and, in lib/zitadel_client.rb, require and configure it:
    require 'warning'
    Warning.ignore(:method_redefined, __dir__)
    This suppresses all :method_redefined warnings for files under our gem directory at runtime.
  • Provide an RBS signature for Warning.ignore so our type checker recognizes the new class method.
  • Document alternative “warning‑free” patch strategies using Module#prepend and define_method in Mustache templates.

Additional Changes

  • Added an RBS (.rbi) entry for Warning.ignore under tapioca/typed/third_party.
  • Included a SimpleCov::Formatter::HTMLFormatter prepend‑patch example showing the same pattern.
  • Updated template‑patch guidance in documentation to cover both the warning gem approach and native Ruby alternatives.

Additional Context

@mridang mridang added the enhancement New feature or request label Apr 22, 2025
@mridang mridang self-assigned this Apr 22, 2025
@mridang mridang changed the title Used the warnings library to fix all the useless method-redeclaration… Suppress method-redefined warnings in generated Ruby SDK models Apr 22, 2025
@mridang mridang merged commit fa5cf7c into main Apr 22, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the models to ensure that fields don't have two setters

1 participant