From: Nikolay Pavlov Date: 2007-11-01T22:55:48+09:00 Subject: How to extend class with the particular method --nextPart3091546.ppBQVWCsWL Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello. I have a class and a module. I want to extend a class with a particular=20 method that is defined in a module. I have come up to the following=20 example code, but i am not sure how to implement a=20 Operational::Behavior#proc method. Could some one please help me in this?=20 Or may be prompt a better implementation? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D class SomeClass include Operational operational_as :bob =20 end module Operational def self.included(base) base.extend ClassMethods end module ClassMethods def operational_as(method) klass =3D class << self; self; end klass.instance_eval do define_method(method.to_sym, Behavior.proc(method.to_sym)) end end end module Behavior def self.proc(method) end private def bob ... end def sam ... end end end =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 =2D Best regards, Nikolay Pavlov. <<<----------------------------------- = =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --nextPart3091546.ppBQVWCsWL Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBHKdrf/2R6KvEYGaIRAtGUAJsHpk4smmbSYZN+K5e+Gt3Y2lOUUACg3rzy ulq/HAE2kyPmDAsGgKOyjK4= =+s1Q -----END PGP SIGNATURE----- --nextPart3091546.ppBQVWCsWL--