Project

patched

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
One-time use refinements
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 5.2
~> 10.1

Runtime

>= 0.6.0.rc4
 Project Readme

Patched

Create one-off refinements for classes, without (most) of the boilerplate.

Installing

Put this in your Gemfile:

gem 'patched'

Or this in your terminal:

gem install patched

Usage

Basically, this:

using patched(ClassName) {
  # add methods to ClassName here
}

The syntax is, unfortunately, quite important.

Example

class LolMaths

  include Patched

  using patched(Fixnum) {
    def to_word
      case self
      when 0 then "zero"
      when 1 then "one"
      when 2 then "two"
      # ...
      end
    end
  }

  def add(*numbers)
    numbers.reduce("") {|sum, num| sum + num.to_word }
  end

end

Tests

Forthcoming.

Contributing

Any ideas or attempts to make this less of a horrible hack would be very much appreciated.