# (no subject)

**URL:** <https://www.ruby-forum.com/t/no-subject/98734>\
**Category:** Ruby\
**Created:** [July 17, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/no-subject/98734 "2006-07-17T21:07:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [July 17, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/no-subject/98734/1 "2006-07-17T21:07:42Z")

</div>

> Daniel B. wrote:

> Well, the idea is that the 3rd party software is going to be using  
> whatever classes it has always used, so just creating a subclass doesn’t  
> get me anywhere because the 3rd party app (i.e. Rails) doesn’t give a  
> hoot about my BigNozzleFiretruck.

You could use a factory for that, and allow the plugin to override the  
factory’s creater method.

#!/usr/bin/env ruby

class FireTruck  
def say  
puts “truck”  
end  
end

class FireTruckFactory  
def FireTruckFactory.create  
return FireTruck.new  
end  
end

# First plugin

class Pumper \< FireTruck  
def say  
puts “Pumper here.”  
end  
end

class FireTruckFactory  
def FireTruckFactory.create  
return Pumper.new  
end  
end

# Second plugin

class HookAndLadder \< FireTruck  
def say  
puts “Hook and ladder here.”  
end  
end

class FireTruckFactory  
def FireTruckFactory.create  
return HookAndLadder.new  
end  
end

#try it  
ft = FireTruckFactory.create  
ft.say # =\> Hook and ladder here.

Regards,  
JJ
