Include and Extend
2011-05-10 16:23:02
2011-05-10 16:22:10
Autor: Sony Santos
http://gigawiki.com/sony/include-and-extend
Permalink: http://gigawiki.com/993
language = English, ruby
module Foo
  def self.included(base)
    base.extend(ClassMethods)
  end
  
  module ClassMethods
    def bar
      puts 'class method'
    end
  end
  
  def foo
    puts 'instance method'
  end
end

class Baz
  include Foo
end
blog comments powered by Disqus
Login:
Senha:
Para logar, você precisa ter o Javascript habilitado.