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
Ruby: Mixin Template

6 thoughts on “Ruby: Mixin Template

  1. rafavega says:

    Hey Ivan sorry for the out of topic question. I’m about to start a wordpress blog about ruby on rails and iPhone programming. What plugin are you using to render the code snippets on your wordpress blog? thanks!

    1. Ivan Torres says:

      Hi rafavega,

      I’m just uploading the Ruby on Rails application that I use to create my snippets. It’s pretty simple to use.

      For WordPress you’ll need “Custom CSS” premium feature and paste the coderay.css (from the app) to your WordPress CSS code.

      Best,
      Ivan

      1. Ivan Torres says:

        Unfortunately I have some problems with Github so I can upload on any of my newly created repos :( I let you know as soon I upload the code.

Leave a comment