This is a great approach for setting config variables. I also like to enable the user to add custom functionality to the gem by accepting a block that is called with any relevant variables for the user to access.<p>For example, in Exceptionally[1], the user can add an initializer that looks like:<p><pre><code> Exceptionally::Handler.before_render do |message, status, error, params|
# put any code here
end
</code></pre>
In the gem, this translates to:<p><pre><code> def self.before_render(&block)
&&callback = Proc.new(&block)
end
</code></pre>
The gem can then call the user's block and give it access to the same variables the rest of the gem does. This approach is a lot simpler than setting up an entire Middleware stack, as suggested in the blog, and makes more sense for simpler gems.<p>1: <a href="https://github.com/neilgupta/exceptionally" rel="nofollow">https://github.com/neilgupta/exceptionally</a>