From: Jeff Barczewski Date: 2007-02-07T04:29:46+09:00 Subject: Best way to do dynamic mixin or dynamic include? (Mixin module name is defined and included at runtime) ------=_Part_12930_24438537.1170790176379 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I am searching for the best way to do a dynamic mixin with Ruby. Basically I have a class that includes a mixin but I want the mixin module name to be driven from configuration and not the code. class A include Foo end but instead of Foo being constant module name, I would this to be driven off of a configuration value. (I'm not too worried about the module being loaded previously that is easily taken care of, so primarily just wanting to know the best way to do a dynamic include). Any opinions on the best way to accomplish this? A very simple way to approach this might be something like ModToInclude = 'Foo' class A eval( "include #{ModToInclude}" ) end Any better ideas? Thanks in advance, Jeff ------=_Part_12930_24438537.1170790176379--