The problem: you want to use some perl class in your Dancer2 app, but there's no plugin for it.

The solution: as long as the class needs only static data to construct an object, then Dancer2::Plugin::Adaptor can do the wrapping for you. Think of it as a "just-in-time" plugin (or maybe a poor-man's Bread::Board).

One or more objects are defined by NAME => HASHREF pairs. The hash reference for each NAME must contain a 'class' key, whose value is the class to wrap.

The 'scope' key determines how long the generated object persists. The choice of scope will depend on whether the object holds onto any state that should not last across requests. The following scope values are allowed:

If the hash reference contains an 'options' key, its value will be dereferenced (if it is a hash or array reference) and passed to new() when the object is created. Note that if the class requires a reference for the constructor, you have to wrap it in an extra array. E.g.