Skip to content

Instantly share code, notes, and snippets.

@ascruggs
Created January 13, 2010 16:33
Show Gist options
  • Save ascruggs/276333 to your computer and use it in GitHub Desktop.
Save ascruggs/276333 to your computer and use it in GitHub Desktop.
module YourNamespacedModule
def self.included(klass)
klass.send :extend, ClassMethods
klass.send :include, InstanceMethods
#klass.belongs_to :some_associated_model #an example of how to use with ActiveRecord
klass.send :attr_accessor, :some_accesor_variable
end
module ClassMethods
def boom
puts "This is just like 'def self.boom' in a class"
end
end
module InstanceMethods
def pow
puts "This is just is just like 'def pow' in a class"
end
end
end
class User
include YourNamespacedModule
end
User.boom
User.new.pow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment