Skip to content

Ignore visibility method, attr definition, module_function within block#1595

Open
tompng wants to merge 1 commit intoruby:masterfrom
tompng:ignore_within_block
Open

Ignore visibility method, attr definition, module_function within block#1595
tompng wants to merge 1 commit intoruby:masterfrom
tompng:ignore_within_block

Conversation

@tompng
Copy link
Member

@tompng tompng commented Feb 4, 2026

We need to ignore these within Module.new do end and any other block because it might be a metaprogramming block.

class A
  def f; end
  X = 1
  anonymous_module = Module.new do
    # These visibility change and attribute defition should be applied to anonymous module, but applied to A
    module_function :f
    private :f
    private_constant :X
    attr_accessor :rw
  end
end

Found while generating document in rails/rails
https://github.com/rails/rails/blob/45ee3bf84f20af55b8619b5dcc22a5e22a4ac0e7/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L307

module ColumnMethods
  class_methods do
    private
    def m; end # This is a private method of unknown class/module
  end

  def g; end # This method should be public, but was treated as private and not documented
end

@tompng tompng requested a deployment to fork-preview-protection February 4, 2026 19:07 — with GitHub Actions Waiting
We need to ignore these within `Module.new do end` and any other block because it might be a metaprogramming block.
@tompng tompng force-pushed the ignore_within_block branch from 3231430 to de00323 Compare February 4, 2026 19:08
@tompng tompng deployed to fork-preview-protection February 4, 2026 19:08 — with GitHub Actions Active
@matzbot
Copy link
Collaborator

matzbot commented Feb 4, 2026

🚀 Preview deployment available at: https://b73ac0d6.rdoc-6cd.pages.dev (commit: de00323)

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