Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

leemeichin/patched

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Use refinements, with a little less boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages