# Overriding code from one engine with another (extending an e

**URL:** <https://www.ruby-forum.com/t/overriding-code-from-one-engine-with-another-extending-an-e/70874>\
**Category:** Engines\
**Created:** [October 3, 2006, 4:31pm UTC](https://www.ruby-forum.com/t/overriding-code-from-one-engine-with-another-extending-an-e/70874 "2006-10-03T16:31:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![folke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9a28c/32.png) [@folke](https://www.ruby-forum.com/u/folke)\
**Post date:** [October 3, 2006, 4:31pm UTC](https://www.ruby-forum.com/t/overriding-code-from-one-engine-with-another-extending-an-e/70874/1 "2006-10-03T16:31:50Z")

</div>

Suppose I want to make an engine that builds on another  
engine. Extending engine code is pretty trivial in the application -  
but what about in another engine?

The specific case I’m looking at here is addition some additional  
authorization framework to the active\_rbac engine. I’ve done this in  
an application already, but I’d like to package those changes up in  
something that can be more easily distributed to other applications  
that may want to use it with active\_rbac.

Can this be done? Am I asking for trouble?

–  
- Adam

\*\* Expert Technical Project and Business Management  
\*\*\*\* System Performance Analysis and Architecture  
\*\*\*\*\*\* [[http://www.adamfields.com](http://www.adamfields.com) ]

[[Adam Fields (weblog) - - entertaining hundreds of millions of eyeball atoms every day](http://www.aquick.org/blog) ] … Blog  
[[Adam Fields Resume](http://www.adamfields.com/resume.html) ]… Experience  
[[Adam Fields | Flickr](http://www.flickr.com/photos/fields) ] … Photos  
[[http://www.aquicki.com/wiki](http://www.aquicki.com/wiki) ]…Wiki

---

<div class="post-metadata">

**Author:** ![folke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9a28c/32.png) [@folke](https://www.ruby-forum.com/u/folke)\
**Post date:** [October 6, 2006, 11:25pm UTC](https://www.ruby-forum.com/t/overriding-code-from-one-engine-with-another-extending-an-e/70874/2 "2006-10-06T23:25:24Z")

</div>

This can be done, although I’m not sure I’d endorse the approach  
(despite the fact that it’s how the user\_engine layers on top of the  
login\_engine at the moment, this may not be the case forever). The key  
is the order in which you start the engines, i.e.

Engines.start :login, :user

puts the user\_engine code in higher priority than the login engine’s  
code. It’s pretty simple.

However - doing this can be pretty complex, and used for anything  
other than your own internal projects, could prove to be more  
complicated to support than you might want to handle. In particular,  
since you’re layering over a plugin from a third party, underlying  
changes can easily break your wrapper engine.

It might be worthwhile seeing if you can incorporate your changes into  
the official active\_rbac codebase instead.

James
