|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have
module A module B module ClassMethods def a_method end end end end ================================================== ============ I would like to be able to class Klass include A::B a_method end ================================================== ============ the interpreter is complaining that a_method does not exist for Klass:Class any ideas? -- Posted via http://www.ruby-forum.com/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Note: parts of this message were removed by the gateway to make it a legal Usenet post.
On 11/5/07, Keynan Pratt <keynan@howe.textdrive.com> wrote: > > I have > > module A > module B > module ClassMethods > > def a_method > end > > end > end > end > ================================================== ============ > I would like to be able to > > class Klass > include A::B > a_method > end > > ================================================== ============ > > the interpreter is complaining that a_method does not exist for > Klass:Class > > any ideas? > -- > Posted via http://www.ruby-forum.com/. > > Try this module A module B module ClassMethods def a_method end end def self.included(base) base.extend(ClassMethods) end end end class Klass include A::B a_method end Michael Guterl |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Nov 5, 5:41 pm, Keynan Pratt <key...@howe.textdrive.com> wrote: > I have > > module A > module B > module ClassMethods > > def a_method > end > > end > end > end > ================================================== ============ > I would like to be able to > > class Klass > include A::B > a_method > end > > ================================================== ============ > > the interpreter is complaining that a_method does not exist for > Klass:Class > > any ideas? $ gem install facets require 'facets/class_extension' module A module B class_extension do def a_method end end end end T. |
|
![]() |
| Outils de la discussion | |
|
|