Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ActiveSupportConcern recursively checks for ClassMethod #1933

Commits on Jun 18, 2024

  1. fix: ActiveSupportConcern recursively checks for ClassMethod

    Problem
    -------
    `ActiveSupportConcern` uses
    [const_defined?](https://apidock.com/ruby/Module/const_defined%3f) to
    check if `ClassMethods` exists on a module. By default, `const_defined?`
    checks the module and its ancestors for the existence of the constant.
    This means that `const_defined?` will return `true` when a module does
    not have `ClassMethods` defined, but one of its ancestors does. This can
    result in `ActiveSupportConcern` generating
    `mixes_in_class_methods.*ClassMethods` lines for invalid
    `.*ClassMethods` modules.
    
    The first commit in this PR adds a negative test case that should fail
    with the existing code.
    
    Solution
    --------
    `const_defined?` takes a second parameter that controls whether to
    include ancestors in the check. Setting this parameter to `false` to
    exclude ancestors.
    spencewenski committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    48aae04 View commit details
    Browse the repository at this point in the history
  2. Exclude ancestors from the const_defined? check

    Set the second parameter of
    [const_defined?](https://apidock.com/ruby/Module/const_defined%3f) to
    false in order to exclude ancestors of the module when checking for the
    existence of the `ClassMethods` constant.
    spencewenski committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    81d481e View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2024

  1. Configuration menu
    Copy the full SHA
    e7d6130 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cdff667 View commit details
    Browse the repository at this point in the history