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

Handle class_methods do blocks for concerns #525

Closed
andyw8 opened this issue Nov 14, 2024 · 2 comments · Fixed by #530
Closed

Handle class_methods do blocks for concerns #525

andyw8 opened this issue Nov 14, 2024 · 2 comments · Fixed by #530

Comments

@andyw8
Copy link
Contributor

andyw8 commented Nov 14, 2024

(details to be added)

cc @toddkummer

@andyw8 andyw8 changed the title Handle class_methods do blocks for concerns Handle class_methods do blocks for concerns Nov 14, 2024
@andyw8
Copy link
Contributor Author

andyw8 commented Nov 22, 2024

@toddkummer this shipped in v0.3.27, if you want to check it's working wth your gem.

@toddkummer
Copy link

The current version of the gem has an extra level of indirection: the main controller mixin includes two modules that each have the class_methods do block.

For example, the gem might be implemented by mixing the module into the ApplicationController:

class ApplicationController < ActionController::Base
  include Filterameter::DeclarativeFilters
  ...

Which then uses one more level of includes...

module Filterameter
  module DeclarativeFilters
    extend ActiveSupport::Concern
    include Filterameter::Filterable
    include Filterameter::Sortable
    ...

To finally get to the class_methods do block...

module Filterameter
  module Filterable
    extend ActiveSupport::Concern
    class_methods do
      ...
      def filter(name, options = {})
      ...

The extra level of indirection seems to prevent the hover and Go To Definition from working. When I collapse it so that the first include has the class_methods do block, it does work. Here is a commit that shows that change.

I was leaning towards making that change anyways, so this fix does resolve my issue. I just wanted to share the additional finding with you in case it is valuable.


I think this confirms I am testing all this on the latest version:

$ less .ruby-lsp/Gemfile.lock | grep ruby-lsp-rails
    ruby-lsp-rails (0.3.27)

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 a pull request may close this issue.

2 participants