Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mixins & Self
module Foo
def save
puts 'in save'
end
end
module Foo
def self.included(resource)
resource.extend ClassMethods
end
def initialize
class << self; lol('haha'); end
end
module ClassMethods
def find
puts 'find'
lol('hehe')
end
end
end
class Bar
include Foo
def self.lol(atr)
puts "in lol #{atr}"
end
end
Bar.find
b = Bar.new
b.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.