An easy way to implement the facade pattern in your classes. In short, this library wraps singleton methods from another class as instance methods of the current class.
gem install facade
gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/facade/main/certs/djberg96_pub.pem)
require 'facade'
class MyString < String
extend Facade
facade Dir # extend all methods
facade File, :dirname, :basename # extend only specified methods
end
f = MyString.new('/home/djberge')
puts f.basename # 'djberge'
puts f.dirname # '/home'
Eero Saynatkari, Eric Hodel and Michael Granger for ideas and code which I shamelessly plagiarized.
Copyright (c) 2005-2023 Daniel J. Berger
Apache-2.0
This package is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose
Daniel J. Berger