Tuesday, September 11, 2012

Ruby - Extends module class methods using 'extend self'

module A
    extend self

    def say_hello
        'A say hello'
    end
end

module B
    extend A
end

A.say_hello # => "A say hello"
B.say_hello # => "A say hello"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.