# Extending instance-methods of an Module for Plugin-Development

**URL:** <https://www.ruby-forum.com/t/extending-instance-methods-of-an-module-for-plugin-development/181715>\
**Category:** Rails\
**Created:** [January 16, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/extending-instance-methods-of-an-module-for-plugin-development/181715 "2010-01-16T20:21:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![k-b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/db5fbb/32.png) [@k-b](https://www.ruby-forum.com/u/k-b)\
**Post date:** [January 16, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/extending-instance-methods-of-an-module-for-plugin-development/181715/1 "2010-01-16T20:21:01Z")

</div>

Don’t know if i should write this to rails or ruby mailinglist. But in  
the  
case i wan’t to extend the facebooker-plugin without touching it, i will  
here.

1. Instance-Methods of modules?  
The methods in a module may be instance methods or module methods.  
Instance  
methods appear as methods in a class when the module is included, module  
methods do not. Conversely, module methods may be called without  
creating an  
encapsulating object, while instance methods may not. (See  
Module#module\_function)

The method which i wan’t to alias in this case is a method which is  
listed,  
when i call:

puts Facebooker::Rails::Helpers.instance\_methods

And it’s not listed, when i call:

puts Facebooker::Rails::Helpers.methods

1. What I wanna do?  
I wan’t to extend facebooker with tracking-functionality for our  
company.  
For this, i want to write an second plugin which is loaded after it  
(beginning with a letter higher then F).  
In this plugin i wan’t to alias the methods from facebooker like

alias\_method :fb\_multi\_friend\_selector\_without\_awesome,  
:fb\_multi\_friend\_selector

And write a new method which do the tracking and call the old

Why can’t i do this with:

module Facebooker  
module Rails  
module Helpers  
alias :fb\_multi\_friend\_selector\_without\_awesome  
:fb\_multi\_friend\_selector  
end  
end  
end

This should just be a normal plain method!!

This don’t work too:

module Facebooker  
module Rails  
module Helpers  
class \<\< self  
alias :fb\_multi\_friend\_selector\_without\_awesome  
:fb\_multi\_friend\_selector  
end  
end  
end  
end

It seems this possibility just works when there are module-methods.

I have tried the following things, but none of this works (for me):

Facebooker::Rails::Helpers::InstanceMethods.module\_eval do  
alias\_method :fb\_multi\_friend\_selector\_without\_awesome,  
:fb\_multi\_friend\_selector  
end

(Don’t work because there are no Instance of the Module … )

Theoretically i can Use the Name of the Class which included the model  
to  
extend it this way. But for me, without any experience on developing on  
rails itself it would be easier if i can extend the classes and modules  
which are only defined in the facebooker-plugin.

Greetings from Germany,  
Klaus

Regards  
kb

> **[Home – Klaus Breyer \> CTO writing about Code, Business, Product &...](https://www.v01.io)**
>
> I have been responsible for technology and teams since I founded my first startup in 2010, right after graduating in Software Engineering. Since then, I have been actively or consultatively involved in several other companies as CTO or CPTO. I...
