Skip to content

Instantly share code, notes, and snippets.

@dougalcorn
Created December 18, 2010 15:29
Show Gist options
  • Save dougalcorn/746595 to your computer and use it in GitHub Desktop.
Save dougalcorn/746595 to your computer and use it in GitHub Desktop.
Simple pattern for how to write modules
module ExtendThroughInclude
def included(klass)
klass.extend(ClassMethods)
klass.send(:include, InstanceMethods)
end
class InstanceMethods
end
class ClassMethods
end
end
TargetClass.send(:include, "ExtendThroughInclude")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment