0.0
No commit activity in last 3 years
No release in over 3 years
Just like in Javascript, convert ruby methods to references that you can pass around and call at a later time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

ToReference

Gem Version Build Status Code Climate

A simple solution to convert any ruby method to a reference. Just like in Javascript, you can pass around and call these references at a later time."

Installation

Add the to_reference gem to your Gemfile:

gem "to_reference"

Update your bundle and run the install generator:

$ bundle install

Usage

Converts both instance and class methods to a reference.

require 'to_reference'

Class Foo
include ToReference

def hi
	"hi"
end

def self.bar(params)
	"gr" + params
end

reference :hi, :bar

Now you can do

ref1 = Foo.new.hi
ref2 = Foo.bar

ref1.call => # "hi"
ref2.call("eat!") => # "great!"

Will also work with methods that are inherited, included, extended etc. Want more examples ? Check out examples

Bugs and Feedback

If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.

http://github.com/sooryaeswaran/to_reference/issues