1 min read

The Greatest Thing Since Sliced Merb

A few days ago, the venerable Fabien Franzen (loob2 on IRC), released a groundbreaking new plugin for Merb that proves just how versatile Merb's core infrastructure is.

His plugin, merb_slices, allows the creation of pluginized models, views, controllers, public assets, etc. that can be dropped into a Merb app and overridden with impunity.

There's a merbunity screencast that can explain it better than I can (and you should really look at it).

The point I want to make, though, is that the entire (rather small) implementation fits squarely inside of the set of public APIs that Merb has exposed, which means that unlike Rails Engines, future releases of Merb are guaranteed not to break the slices plugin.

Just to be clear, when I say public APIs, I don't mean Ruby's public visibility. Merb's public APIs are tagged in our documentation and are a contract with our users: "We won't break this method without a LOT of thought and explicit warnings. Everything else, however, we can and will change with impunity." This gives us a lot of power to go in and refactor large swaths of Merb without substantially changing the way that developers interact with the framework.

And it gives plugin authors like Fabien the confidence to build substantial pieces of functionality that extend Merb without fearing that the next version of Merb will break their plugin out of the blue.

Again, go watch the screencast; I think you'll be quite impressed with how much functionality can be layered on top of just Merb's public APIs.

As a final word, there was a single piece of functionality that Fabien used that wasn't public. As a result of his experience, we looked at all of the available options and agreed that it needed to be made public (but changed the way it was accessed to make it easier to refactor internals without modifying the public interface). On the Merb team, if you want to build a plugin that hooks into Merb but can't do it with just the public APIs, we likely consider that a bug to be fixed.

We consider cases of people using alias_method_chain on Merb to be a bug in Merb, and try to find ways to expose enough functionality so it will not be required.

Good night, and Good luck!