# Calling instance method when module included

**URL:** <https://www.ruby-forum.com/t/calling-instance-method-when-module-included/138913>\
**Category:** Ruby\
**Created:** [May 28, 2008, 11:01pm UTC](https://www.ruby-forum.com/t/calling-instance-method-when-module-included/138913 "2008-05-28T23:01:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/22d042/32.png) [@leonb](https://www.ruby-forum.com/u/leonb)\
**Post date:** [May 28, 2008, 11:01pm UTC](https://www.ruby-forum.com/t/calling-instance-method-when-module-included/138913/1 "2008-05-28T23:01:09Z")

</div>

Hi all,

Maybe a silly question, but is it possible to call instance methods on  
an object when you’ve included a module? Or maybe I’m having the wrong  
approach and somebody can point me in the right direction?

I’m now doing something like:

a = [‘one’, ‘two’, ‘three’]  
a.send(:include, InstanceMethods)

And the InstanceMethods module looks like:

module InstanceMethods

def self.included(base)  
base.instance\_eval do  
self.each do |item|  
p item  
end  
end  
end  
end

Now I’m getting everytime: NoMethodError: undefined method `each’ for  
Array:Class

So my question: is a construction like this possible? If yes, how then?  
If no: is there a better way to achieve this then? Or should I drop the  
idea and first include the module and THEN create the object?

In this context it’s maybe a bit silly, but I didn’t want to post the  
code in which I’m trying to use this construct because then it maybe  
distracts from the idea I’m trying to achieve.

Thanks in advance all!
