Function magnus::block::block_proc

source ·
pub fn block_proc() -> Result<Proc, Error>
Expand description

Returns the block given to the current method as a Proc instance.

§Panics

Panics if called from a non-Ruby thread. See Ruby::block_proc for the non-panicking version.

§Examples

use magnus::{
    block::{block_proc, Proc},
    define_global_function, function, rb_assert, Error,
};

fn make_proc() -> Result<Proc, Error> {
    block_proc()
}

define_global_function("make_proc", function!(make_proc, 0));

rb_assert!("make_proc {}.is_a?(Proc)");