Forum: Ruby on Rails Internal plugin architecture, where to start from

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Davide B. (Guest)
on 2009-06-05 13:01
Hello folks.
I am refactoring a simple CMS, and looking to implement a simple
internal plugin architecture.
I have a MenuItem class. By default, menu items can be, say, 'article'
or 'sitemap', or 'newsroll'. I want to implement a hook to which my
modules can plug, so I will be able to add other tipologies (like
"catalog", "gallery" or whatever) through modules, which are aptly
structured plugins.
Presently, I have something like this:

[code=]class MenuItem < ActiveRecord::Base
  belongs_to :article
  @tipologies = Array.new
  @tipologies.push("article","sitemap")
  def self.tipologies
    return @tipologies
  end
  def self.addTipology(item)
    @tipologies.push(item)
  end
end[/code]
I have been able to add an item to @typologies through a plugin, with
this init.rb

[code=]ActionController::Base.send :include,  Tipeadder[/code]
And this is the main plugin code (obviously I am just sketching here):

[code=]# Tipeadder.rb
module Tipeadder
  MenuItem.addTipology("cane")
  MenuItem.addTipology("gatto")
end[/code]

Yet the type is added only when the app is first loaded, then it gets
lost.
I am a also bit lost here. I have been using plugin architectures for
ages in Wordpress development, but never implemented one, so i am not
sure I am going the right way.
Have you go some general advice on the procedure I should follow? Which
is the best and most ruby-like way to do this?
Thanks,
Davide
This topic is locked and can not be replied to.