Newbie mixin question

Hi,
Just 2 questions:

  1. How can I mixin a class method (not an instance method)?

  2. How can I force a certain method to be called when the an object of a
    class that includes that module is initialized? Sort of like a mixin
    initialize…

TIA
Michael Garriss

Michael Garriss wrote:

  1. How can I force a certain method to be called when the an object of a
    class that includes that module is initialized? Sort of like a mixin
    initialize…

Define initialize in the module, and call super from the class which
mixes it in.

Hi,

  1. How can I mixin a class method (not an instance method)?

module Foo
def foo
p “foo”
end
end

class Bar
Bar.extend(Foo)
end

Bar.foo

						matz.
···

In message “newbie mixin question” on 03/08/12, Michael Garriss mgarriss@earthlink.net writes:

[matz:]

class Bar
Bar.extend(Foo)
end

Alternatively

class Bar
extend Foo
end

Gavin