# Proposal for generic matching of names in dependency autoloa

**URL:** <https://www.ruby-forum.com/t/proposal-for-generic-matching-of-names-in-dependency-autoloa/112621>\
**Category:** Engines Development\
**Created:** [August 21, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/proposal-for-generic-matching-of-names-in-dependency-autoloa/112621 "2007-08-21T14:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [August 21, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/proposal-for-generic-matching-of-names-in-dependency-autoloa/112621/1 "2007-08-21T14:52:20Z")

</div>

Hi engines developers,

I’m working on a project that uses Cells extensively  
([http://nick.smt.de/trac/nick/wiki/Cells](http://nick.smt.de/trac/nick/wiki/Cells)). Cells relies on Engines in  
turn. I hit a wall when I tried to make cells load a class tree of  
cells  
This was caused by the way Cells works, but I will not bother you with  
the boring details of that.

I decided to rework the way cells loads its classes, and the best way to  
do  
this is via the autoload dependencies system, which is overridden by  
Engines.  
This requires that the correct file is loaded not only when the user  
refers  
to FooController (from controllers/foo\_controller.rb), but also when the  
user refers to FooCell (from cells/foo\_cell.rb).

This can be done by copying over the entire  
require\_or\_load\_with\_engine\_additions and adding ‘cell’ to the  
file\_types,  
but that would be silly and very un-DRY. Instead, I propose this patch  
(see attachment). It adds a new mattr\_accessor Engines.file\_types which  
defaults to [‘controller’, ‘helper’]. Cells then adds to this so it  
reads  
[‘controller’, ‘helper’, ‘cell’] and hacks the load paths in such a way  
that the correct load paths are looked up.

In my opinion, this small patch paves the way for other cell-like  
extensions  
to Rails, so I would like to see this integrated in Engines.

Comments? Suggestions?

Regards,  
Peter B.  
Solide ICT - [http://www.solide-ict.nl](http://www.solide-ict.nl)

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [August 21, 2007, 3:02pm UTC](https://www.ruby-forum.com/t/proposal-for-generic-matching-of-names-in-dependency-autoloa/112621/2 "2007-08-21T15:02:21Z")

</div>

Hi Peter -

This looks like a very reasonable patch. The only thing I might ask is  
that we think of a better name than “file\_types”, as  
“Engines.file\_types” doesn’t really nail which its values are being  
used for. My first thought was “Engines.file\_types\_to\_mix”, although  
I’m definitely open to suggestions.

If you submit this as a patch to [http://dev.rails-engines.org](http://dev.rails-engines.org), it will  
get committed in the very near future.

Thanks again!

James

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [August 21, 2007, 3:23pm UTC](https://www.ruby-forum.com/t/proposal-for-generic-matching-of-names-in-dependency-autoloa/112621/3 "2007-08-21T15:23:26Z")

</div>

On Tue, Aug 21, 2007 at 02:01:36PM +0100, James A. wrote:

> Hi Peter -
> 
> This looks like a very reasonable patch. The only thing I might ask is  
> that we think of a better name than “file\_types”, as  
> “Engines.file\_types” doesn’t really nail which its values are being  
> used for.

Agreed, this name was just something I came up with quickly to test if  
this  
approach would work. It should be more descriptive.

> My first thought was “Engines.file\_types\_to\_mix”, although  
> I’m definitely open to suggestions.
> 
> If you submit this as a patch to [http://dev.rails-engines.org](http://dev.rails-engines.org), it will  
> get committed in the very near future.

I did, and I added a couple of suggestions for a more descriptive name  
to  
the ticket. Let’s continue discussion there, if needed.

Regards,  
Peter B.  
Solide ICT - [http://www.solide-ict.nl](http://www.solide-ict.nl)
