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

Stop setting icons through method_missing #42

Closed
Angelmmiguel opened this issue Mar 14, 2022 · 0 comments · Fixed by #43
Closed

Stop setting icons through method_missing #42

Angelmmiguel opened this issue Mar 14, 2022 · 0 comments · Fixed by #43
Assignees
Labels
Milestone

Comments

@Angelmmiguel
Copy link
Owner

Angelmmiguel commented Mar 14, 2022

As today, the way to set the icon in a specific material icons instance is to call a method:

mi.calendar

This approach is based on the special method_missing method from Ruby. At the beginning, I decided to use this approach as it simplifies the way you set the icon. However, I quickly noticed some drawbacks:

  • You miss real exceptions when calling methods that doesn't exist in that class. This may make more difficult to debug certain issues
  • There are icons that starts with a number, which it's invalid for ruby methods

Now, checking the new PR to upgrade the gem to 4.0.0, I noticed many new icons starting with a number. For this reason, I plan to move from this approach to a specific method in v4.0.0.

Note this is a breaking change and already existing users would need to change their code:

# v2.2.0 and before
mi.calendar

# v4.0.0
mi.shape(:calendar)
mi.shape('calendar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant