Include and Extend
2011-05-10 16:23:02
2011-05-10 16:22:10
Autor: Sony Santos
https://gigawiki.com/sony/include-and-extend
Permalink: https://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