From: David Vallner Date: 2006-10-02T04:14:33+09:00 Subject: Re: dynamic include --------------enig8BA334A3E1BAE200D6F13945 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Florian A=DFmann wrote: > To be complete here if the Exception: >=20 > NameError: undefined local variable or method `role' for > #> > I smell a Ruby bug / gotcha. Apparently, in metaclass scope, the surrounding scope just isn't visible.= Try a workaround: person.roles.each do |role| if role.class.const_defined?('Functions') class << person self end.class_eval do include role.class.const_get('Functions') end end end unless person.nil? David Vallner PS: Statement modifiers after whole blocks? Ick. --------------enig8BA334A3E1BAE200D6F13945 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFIBOXy6MhrS8astoRAufoAJ4lgMrk/HCYYhnJL9j8x3UOMtRczwCdGLG0 7tV6V4mk/oWy6lsM8TeKOBY= =4lJR -----END PGP SIGNATURE----- --------------enig8BA334A3E1BAE200D6F13945--