Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A terrible idea using Ruby's metaprogramming facilities.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
README

README

# Overloadable

A quick and dirty proof of concept to see how easy it is to implement
method overloading in Ruby based on duck typing.

# Usage

**NB: Usage is NOT advised in any capactiy.**

    require 'function_overload'

    class Foo
      extend Overloadable

      # will be called only with objects that respond_to?(:split)
      def bar(baz_split)
        baz_split.split('-')
      end

      # will be called only with objects that respond_to?(:reverse)
      def bar(baz_reverse)
        baz_reverse.reverse
      end
    end

Can be used to create functions of different arities as well. See the
specs for more examples.
Something went wrong with that request. Please try again.