Skip to content

Class.new's internal method becomes the method of the class to which the method belongs #816

@gemmaro

Description

@gemmaro

The methods owned by the dynamically generated class inside the method are defined as the methods of the class outside of it.
The explanation is a bit complicated, so please see the example.

aaa.rb:

class AAA
  def bbb
    Class.new do
      def ccc; end
    end
  end
end
$ rdoc aaa.rb

There are both bbb and ccc as Public Instance Methods of class AAA.

Screenshot 2021-06-19 at 18-31-44 class AAA - RDoc Documentation

$ rdoc --version
6.3.1

$ ruby --version
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions