I decided to go the ActiveSupport::Concern strategy. The reason is that a co-worker said he had done the Class.class_eval strategy suggested by Forem/Spree (see Ryan Bigg's comment), and this would randomly break. The basic ActiveSupport::Concern strategy looks like this. https://gist.github.com/3132025
Currently the dummy app is functional and rspec can run a simple test. https://github.com/thelabtech/questionnaire/commit/20239148549f9aa8dafc6d76435de6614a2a9753 I'll continue working on the gem (Questionnaire, :branch => activesupport<https://github.com/thelabtech/questionnaire/tree/activesupport>) and will be folding it into a Rails applicaiton (ccc360, :branch => rails32<https://github.com/thelabtech/ccc360/tree/rails32> ). On Sunday, July 15, 2012 3:57:00 AM UTC-4, mschuerig wrote: > > On Friday 13 July 2012, Weston Platter wrote: > > What's the benefit and/or difference between > > Forem's controller/model Module::Class.class_eval strategy > > Wicked Wizard ActiveSupport::Concern strategy > > The first, reopening a class and defining methods, just adds new methods > by adding them to the class. If there already was a method of the same > name, it is redefined. > > The later, including a concern in an existing class, adds methods by > including a module containing them. This module is inserted into the > inheritance chain just above the class itself but before any > superclasses and previously included modules. Therefore, methods defined > in such a module override those in the inheritance chain, but can access > them through super. However, methods defined in the including class > itself take precedence over those in any included module. > > As such, IMO, the best way to ensure extensibility of a class is to > define its functionality in modules and have the class itself contain > barely more that a list of includes. That way, extensions can be > included from new modules while still keeping the original functionality > accessible to them. In particular, this avoids renaming methods with > alias_method_chain or similar. > > Michael > > -- > Michael Schuerig > mailto:[email protected] > http://www.schuerig.de/michael/ > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/mvO66EuooCwJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
