I usually use this code in my own file under the lib / ext folder. You can then request this file from your Sinatra application.
In lib / ext / string.rb:
class String my_mythod some_code end end
Then add the following to your Sinatra application, assuming your base class file is inside the lib folder:
require File.dirname(__FILE__) + '/ext/string'
I would be interested to know what people think about it.
source share