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 arity warning for template handlers #35858

Conversation

localhostdotdev
Copy link
Contributor

@localhostdotdev localhostdotdev commented Apr 4, 2019

Summary

The warning displayed a generic Class string instead of the class name (e.g. Coffee::Rails::TemplateHandler).

This makes it difficult to know which template handler is responsible for the warning and thus which one needs to be updated.

extensions could also be used and may lead to a better error message.

Other Information

handler.class # => Class

handler.to_s # => Coffee::Rails::TemplateHandler

Change:
  >> Class#call(template)
To:
  >> Class#call(template, source)

to

Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)

A test would be great, not sure how I would do that though (either using an old gem version or mocking a template handler). At least it works in my manual testing.

I also fixed the instance method call to a class method call as this is how Coffee::Rails::TemplateHandler handles it:

Coffee::Rails::TemplateHandler.call(OpenStruct.new(source: 'a = 1'), 'a = 1')

Mainly to help with knowning which template is reponsible for the
warning.

handler.class # => Class

handler.to_s # => Coffee::Rails::TemplateHandler

Before:

Change:
  >> Class#call(template)
To:
  >> Class#call(template, source)

After:

Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)
@rails-bot rails-bot bot added the actionview label Apr 4, 2019
@localhostdotdev
Copy link
Contributor Author

cc: @tenderlove as you seem be the one who knows the most about this (💜💙💚💛🧡❤️)

@rafaelfranca rafaelfranca merged commit 3809e3e into rails:master Apr 4, 2019
@localhostdotdev localhostdotdev deleted the add-extensions-to-arity-error-message branch April 4, 2019 17:45
@connorshea
Copy link
Contributor

This’ll help me a lot with finding where my only remaining Rails 6 depreciation warning is, thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants