Ruby: Mixin Template

This is the basic structure I use to create a mixin in Ruby:

# = Mixin Template
# == Usage
# ActionController::Base.send :include, MixinModuleName
 
module MixinModuleName
 
  def self.included(recipient)
    recipient.extend(ClassMethods)
    recipient.class_eval do
      include InstanceMethods
    end
  end
 
  module InstanceMethods
  end
  
  module ClassMethods
  end
  
end
Advertisements
Ruby: Mixin Template