# Using object methods of first module in methods of second module

**URL:** <https://www.ruby-forum.com/t/using-object-methods-of-first-module-in-methods-of-second-module/133952>\
**Category:** Ruby\
**Created:** [April 5, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/using-object-methods-of-first-module-in-methods-of-second-module/133952 "2008-04-05T14:34:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nixon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/5fc32e/32.png) [@nixon](https://www.ruby-forum.com/u/nixon)\
**Post date:** [April 5, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/using-object-methods-of-first-module-in-methods-of-second-module/133952/1 "2008-04-05T14:34:48Z")

</div>

Beforehand sorry for my English, I’m from Russia.

I have 2 modules:

module SendMail  
def self.send\_mail(hash)  
# some code  
end  
end

module ActionMailer  
def quoted\_printable(text, charset)  
# some code  
end  
end

Please say me, is there any way to have access to method  
“quoted\_printable” of module ActionMailer from method send\_mail of  
module SendMail. It would be good, if I pass using Classes in this  
situation, because I want to divide  
namespaces correctly.

---

<div class="post-metadata">

**Author:** ![nixon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/5fc32e/32.png) [@nixon](https://www.ruby-forum.com/u/nixon)\
**Post date:** [April 6, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/using-object-methods-of-first-module-in-methods-of-second-module/133952/2 "2008-04-06T21:59:22Z")

</div>

2008/4/5, Nikita P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> # some code
> 
> ```
> 
> end  
> end
> 
> Please say me, is there any way to have access to method  
> “quoted\_printable” of module ActionMailer from method send\_mail of  
> module SendMail. It would be good, if I pass using Classes in this  
> situation, because I want to divide  
> namespaces correctly.

Nikita, quoted\_printable is an instance method. So you need to have an  
instance of a class which includes the ActionMailer module. If you  
have such an instance, you can call its quoted\_printable method.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![nixon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/5fc32e/32.png) [@nixon](https://www.ruby-forum.com/u/nixon)\
**Post date:** [April 6, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/using-object-methods-of-first-module-in-methods-of-second-module/133952/3 "2008-04-06T22:49:55Z")

</div>

On Apr 6, 2008, at 3:59 PM, Pit C. wrote:

> > def quoted\_printable(text, charset)  
> > Nikita, quoted\_printable is an instance method. So you need to have an  
> > instance of a class which includes the ActionMailer module. If you  
> > have such an instance, you can call its quoted\_printable method.

If you want the object to be the SendMail module itself then extend  
SendMail with ActionMailer:

module ActionMailer  
def quoted\_printable(text, charset)  
# some code  
end  
end

module SendMail  
extend ActionMailer  
def self.send\_mail(hash)  
# some code  
quoted\_printable(…)  
end  
end
