0.0
No commit activity in last 3 years
No release in over 3 years
Convert proc to lambda, retain the context.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

proc-to-lambda

Build Status Gem Version Coverage Status

Introduction

Convert proc to lambda, retain the context.

Install

gem install 'proc-to-lambda'

Usage

You can use the method directly by invoke the method to_lambda of ProcToLambda.

my_proc = proc { return self + 1 }
my_lambda = ProcToLambda.to_lambda(my_proc)

# `return` works here, and can retain `self`
1.instance_exec(&my_lambda) # => 2

Or, you can include or extend the ProcToLambda module.

include ProcToLambda

def foo
  to_lambda(proc {})
end
# beware, this is risky.
Proc.extend(ProcTolambda)

Proc.to_lambda(proc {})

More

You can see also test cases.