Created
January 13, 2010 16:33
-
-
Save ascruggs/276333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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