# Turning a proc into a method?

**URL:** <https://www.ruby-forum.com/t/turning-a-proc-into-a-method/119774>\
**Category:** Ruby\
**Created:** [November 10, 2007, 11:04am UTC](https://www.ruby-forum.com/t/turning-a-proc-into-a-method/119774 "2007-11-10T11:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unnali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/97f17d/32.png) [@unnali](https://www.ruby-forum.com/u/unnali)\
**Post date:** [November 10, 2007, 11:04am UTC](https://www.ruby-forum.com/t/turning-a-proc-into-a-method/119774/1 "2007-11-10T11:04:57Z")

</div>

Hi all,

Any ideas on how to convert a proc into a method? Here’s an example,  
but…  
it seems not so great.

class Proc  
def to\_global\_method  
func = self  
Kernel.module\_eval { define\_method(:some\_name) { |\*a| func.call \*a }  
}  
end  
end

Cheers,  
Arlen.

---

<div class="post-metadata">

**Author:** ![unnali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/97f17d/32.png) [@unnali](https://www.ruby-forum.com/u/unnali)\
**Post date:** [November 10, 2007, 11:16am UTC](https://www.ruby-forum.com/t/turning-a-proc-into-a-method/119774/2 "2007-11-10T11:16:43Z")

</div>

Arlen Christian Mart C. wrote:

> Any ideas on how to convert a proc into a method? Here’s an example, but…  
> it seems not so great.

> ```
> func = self
> Kernel.module_eval { define_method(:some_name) { |*a| func.call *a } }
> 
> ```

Kernel.send(:define\_method, :some\_name, &self)

HTH,  
Sebastian

---

<div class="post-metadata">

**Author:** ![unnali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/97f17d/32.png) [@unnali](https://www.ruby-forum.com/u/unnali)\
**Post date:** [November 10, 2007, 11:34am UTC](https://www.ruby-forum.com/t/turning-a-proc-into-a-method/119774/3 "2007-11-10T11:34:15Z")

</div>

Hi,

> Arlen Christian Mart C. wrote:  
> Kernel.send(:define\_method, :some\_name, &self)
> 
> ## HTH, Sebastian
> 
> Jabber: removed\_email\_address@domain.invalid  
> ICQ: 205544826

Exactly! Thank you very much.

Arlen
