# Modules and foo

**URL:** <https://www.ruby-forum.com/t/modules-and-foo/73357>\
**Category:** Ruby\
**Created:** [October 24, 2006, 2:45am UTC](https://www.ruby-forum.com/t/modules-and-foo/73357 "2006-10-24T02:45:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cuspendlove](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@cuspendlove](https://www.ruby-forum.com/u/cuspendlove)\
**Post date:** [October 24, 2006, 2:45am UTC](https://www.ruby-forum.com/t/modules-and-foo/73357/1 "2006-10-24T02:45:44Z")

</div>

I have some questions about some things that i don’t understand…  
here is some code fragments

I have two questions.

One… is there a better way to inherit between modules  
that i don’t know about?

Two… why, when a method is called in module Bar does the Module  
InstanceMethods in Bar not get included?

module Blah  
def self.append\_features(base)  
super  
base.extend ClassMethods  
end  
module InstanceMethods  
def visible

```
       end
  end
  module ClassMethods

         def _do_other

	class_eval <<-EOV
	  include InstanceMethods
	EOV

    end

         def do_blah
	"blah"
         end
  end

```

end

module Bar  
def self.append\_features(base)  
super  
base.extend ClassMethod

# 

# This is ugly

# How do i avoid this?

# 

```
       base.extend Blah::ClassMethods
  end
  module InstanceMethods
       def hidden

       end
  end
  module ClassMethods
	def do_bar
		do_blah
		 #
		 #
		 # When i do this , i don't get the InstanceMethods of Bar, just Blah
		 #
		_do_other
	end
  end

```

end

---

<div class="post-metadata">

**Author:** ![cuspendlove](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@cuspendlove](https://www.ruby-forum.com/u/cuspendlove)\
**Post date:** [October 24, 2006, 7:52pm UTC](https://www.ruby-forum.com/t/modules-and-foo/73357/2 "2006-10-24T19:52:56Z")

</div>

Curtis S. wrote:

> ```
> end
> end
> 
> ```

Do you mean “class InstanceMethods”? Modules are collections, often of  
classes.

-Nate

---

<div class="post-metadata">

**Author:** ![cuspendlove](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@cuspendlove](https://www.ruby-forum.com/u/cuspendlove)\
**Post date:** [October 24, 2006, 11:37pm UTC](https://www.ruby-forum.com/t/modules-and-foo/73357/3 "2006-10-24T23:37:14Z")

</div>

> > ```
> > end
> > end
> > 
> > ```
> 
> Do you mean “class InstanceMethods”? Modules are collections, often  
> of classes.

I’m following a pattern that Rails uses for the “Acts As” code.

I don’t want to muddle with the inheritance tree, i just want to mix-  
in methods.
