Skip to content

sooryazeal/to_reference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages