If you''ve been programming for a while you''ve probably heard of Aspect Oriented Programming. Now AOP is good, as it reduces complexity for developers and when combined with modules it also allows system administrators more freedom in what parts of the software they want to run. As Ruby is a very dynamic language (Mixins, and all classes are open) and Rails already provides quite some hooks like before-, after, and validation- filters in models and controllers we are already half way there. Now even better: the excellent plugins_plus plugin (http://svn.pluginaweek.org/trunk/plugins/rails/plugins_plus/) already almost does what we want. It allows one to put code in their default places inside the lib (like app/models) that is then merged with your application''s code automatically (like Rails Engines). What is missing is a way to output data from plugins into existing views and layouts. For this I made the BodyBuilderModule. (http://logilogi.svn.sourceforge.net/viewvc/logilogi/trunk/lib/modules/body_builder_module.rb?view=markup) That module allows one to create hooks for places where content can be inserted in views. In short it allows one to set body_parts (variables that can be included in views, like @pre_body) from controllers. Together with the plugins_plus plugin this allows you to develop modules that mix in automatically at the level of Models, Controllers and (thanks to the body builder module) Views. You can declare body-parts (variables like @left_body) inside a controller with: body_parts :left, :pre # etc... You should do this inside a plugin that is loaded before the plugins that will be adding to it. In case of Manta this is the [http://logilogi.svn.sourceforge.net/viewvc/logilogi/trunk/vendor/plugins/manta_modulizer/ MantaModulizer plugin]. Now in other plugins (and in the main app) you can add to the body-parts with: left_body :my_method, :my_other_method (for this ''body-part :left'' must have been declared) Then in view in your app you can include @left_body, and it will contain all that my_method, my_other_method, (and possibly more methods in different modules) have returned after you''ve called build_bodies as a before_filter. You can get the modules here: https://logilogi.svn.sourceforge.net/svnroot/logilogi/trunk/lib/modules/body_builder_module.rb https://logilogi.svn.sourceforge.net/svnroot/logilogi/trunk/lib/extensions/module.rb (an extension to the module class is needed to allow mixing in both class and normal methods...) So now go forth and multiply your app''s aspects... If you think this module might be usefull for wider application I could pack it up as a plugin. Also if you have any comments on how it could be improved (in relation to yield for example) they''re welcome... greetings, Wybo Wiersma -- ::Student: - History, Informatiekunde (computer linguistics, IR, webtech) and Philosophy - Member of the Center for Metahistory Groningen (http://www.rug.nl/let/cmg) ::Free Software and Open Source Developer: - http://www.LogiLogi.org, Cumulative, shared commenting, publication and idea sharing: Where insight comes together... - ComLinToo, a computational linguistics toolset written in Perl - Lake (LogiLogi.org Make), a make-replacement using makefiles in pure C++ ::Being: - In the world, wavy hair, go figure (http://nl.logilogi.org/HomE/WyboWiersma) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---