module Persistence
def self.included(klass)
klass.extend(ClassMethods)
end
module ClassMethods
def all
puts 'all'
end
def find(id)
puts "looking for entity with id=#{id}"
end
end
def save
puts 'saving'
end
def update
puts 'updating entity'
end
end
class User
include Persistence
end
u = User.new
# instance methods
u.save #=> saving
u.update #=> updating entity
# class methods
User.all #=> all
User.find(1) #=> looking for entity with id=1