Skip to content
main
Switch branches/tags
Code

Latest commit

In addition to the straightforward changes required for the CI configuration, there are a few other changes included in this PR.

The first change was the Gemfile.lock in the base of the repo.  I updated it to be Rails 7.0.1 as opposed to 7.0.0.alpha.2.  This required including a few explicit RAILS_VERSION environment variables for certain steps in CI and linting.

Two additional items required to get the specs to green were changes to some argument handling and module prepending.

To disambiguate with keyword arguments, it was necessary to add an explicit hash in the lib/view_component/instrumentation.rb implementation of render_in.

The second issue, which was a bit more subtle, has to do with the change to how module prepending works IF the module is already in the ancestor chain.  This is discussed here - https://rubyreferences.github.io/rubychanges/3.1.html#moduleprepend-behavior-change .

Because of initializer code in lib/view_component/engine.rb, the ViewComponent::Instrumentation module is prepended to ViewComponent::Base on engine load.  But the prepend call is made for a second time when ViewComponent::Instrumentation is explicitly included.  In Ruby 3.0 and earlier this second call is a no-op, but in Ruby 3.1 it adds a second ViewComponent::Instrumentation to the ancestor chain, resulting in a duplicate invocation of the notification.

My sense is that there's no reason for the self.included call in ViewComponent::Instrumentation (and in fact, no reason for a component to explicitly include ViewComponent::Instrumentation at all), but given my limited familiarity with the internals of the library I simply restored the Ruby 3.0 and earlier behavior for this case.
5d8413c

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

ViewComponent logo ViewComponent logo

A framework for building reusable, testable & encapsulated view components in Ruby on Rails.

Documentation

See viewcomponent.org for documentation.

Contributing

This project is intended to be a safe, welcoming space for collaboration. Contributors are expected to adhere to the Contributor Covenant code of conduct. We recommend reading the contributing guide as well.

License

ViewComponent is available as open source under the terms of the MIT License.