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

Make Hanami::View::Rendering::LayoutScope to inherit from Hanami::Utils::BasicObject #160

Merged
merged 4 commits into from
Sep 25, 2019

Conversation

jodosha
Copy link
Member

@jodosha jodosha commented Sep 25, 2019

What

Make Hanami::View::Rendering::LayoutScope to inherit from Hanami::Utils::BasicObject instead from Ruby's BasicObject.

This ensures a better interoperability with latest tilt changes. See rtomayko/tilt#347

Technical details

  • Hanami::View::Rendering::LayoutScope#is_a? is no longer implicitly dispatched to the internal @scope as per effect of #method_missing. Because Hanami::Utils::BasicObject implements #is_a?, #method_missing is no longer called. It's important for Hanami::View::Rendering::LayoutScope to take control on #is_a? because it led to unexpected behaviors like is_a?(Module) to return true, because the current @scope was a Module. Of course Hanami::View::Rendering::LayoutScope isn't a Module, but a basic object, and #is_a? must reflect it.

  • Hanami::View::Rendering::LayoutScope#class was removed because it's already implemented by the new superclass: Hanami::Utils::BasicObject.

  • The behavior of #inspect is extracted into the private method #__inspect. This is a Utils::BasicObject hook to allow its subclasses to define their own inspect logic. Hanami::View::Rendering::LayoutScope will still continue to respond to #inspect and to return the same inspecting string. The implementation is now split between the new superclass and the layout scope itself.

  • Gemfile temporary points to hanami-utils branch that contains another Utils::BasicObject fix that makes hanami-view build to pass with tilt 2.0.10. See Let Utils::BasicObject to lookup constants at the top-level namespace utils#343

…Utils::BasicObject` instead from Ruby's `BasicObject`
… already implemented by its new superclass: `Hanami::Utils::BasicObject`
@jodosha jodosha added the fix label Sep 25, 2019
@jodosha jodosha requested a review from a team September 25, 2019 07:36
@jodosha jodosha self-assigned this Sep 25, 2019
…ject inspection.

NOTE: this isn't a breaking change `Hanami::View::Rendering::LayoutScope` still
respond to `#inspect` and it still returns the same inspection string.
The behavior now it's just split with the superclass, because
`Utils::BasicObject` already implements logic to print class name and
object ID.
@jodosha jodosha added this to the v1.3.2 milestone Sep 25, 2019
@jodosha jodosha merged commit 1350b35 into master Sep 25, 2019
@jodosha jodosha deleted the fix/rendering-layout-scope-utils-basic-object branch September 25, 2019 08:22
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 this pull request may close these issues.

None yet

2 participants