Project

facade

0.0
No release in over 3 years
Low commit activity in last 3 years
The facade library allows you to mixin singleton methods from classes or modules as instance methods of the extending class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.9
 Project Readme

Ruby

Synopsis

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.

Installation

gem install facade

Adding the trusted cert

gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/facade/main/certs/djberg96_pub.pem)

Usage

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'

Acknowledgements

Eero Saynatkari, Eric Hodel and Michael Granger for ideas and code which I shamelessly plagiarized.

Copyright

Copyright (c) 2005-2023 Daniel J. Berger

License

Apache-2.0

Warranty

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

Author

Daniel J. Berger