interagent / pliny

An opinionated toolkit for writing excellent APIs in Ruby.
MIT License
802 stars 73 forks source link

Fix sinatra extension registration #337

Closed bensymonds closed 4 years ago

bensymonds commented 4 years ago

It seems like pliny is not configuring its Serialize extension correctly. The extensions guide explains how to extend the DSL (as Serialize is doing here with its serializer method) - using register.

As is stands this module is depending on internal behaviour of sinatra - that it uses include to pull in helpers - so it was always at risk of breaking. In sinatra 2.1 it finally broke - the internal behaviour changed to use prepend.

336 is a simple fix for this - switching the module to assume it is prepended rather than included - but there is no guarantee this behaviour won't change and break things again. Unfortunately the problem with this change is it requires a change in applications using pliny:

- helpers Pliny::Helpers::Serialize
+ register Pliny::Helpers::Serialize

I would probably just take the hit and go with this change, so we're protected from changes in future. Given pliny is still on a 0.x.y version it's "allowed" (according to SemVer) to break stuff. I doubt the number of applications using pliny is large, so we're not generating a large amount of effort downstream because of this.