hoangdangninh
1/23/2017 - 5:58 PM

From http://culttt.com/2015/07/08/working-with-mixins-in-ruby/

module Utilities
  def method_one
    puts "Hello from an instance method"
  end
 
  module ClassMethods
    def method_two
      puts "Hello from a class method"
    end
  end
end

def self.included(base)
  base.extend(ClassMethods)
end

class User
  include Utilities
end

 
#User.new.method_one
#=> Hello from an instance method
 
#User.method_two
#=> Hello from a class method