Skip to content

Instantly share code, notes, and snippets.

@slant
Created May 3, 2012 05:50
Show Gist options
  • Select an option

  • Save slant/2583612 to your computer and use it in GitHub Desktop.

Select an option

Save slant/2583612 to your computer and use it in GitHub Desktop.
A file to demonstrate the difference between extending with ActiveSupport::Concern and without
require 'rubygems'
require 'active_support'
module Stuff
# New hotness
extend ActiveSupport::Concern
def whatnot
6
end
# Old and busted
# def self.included(base)
# base.send :include, InstanceMethods
# base.send :extend, ClassMethods
# end
#
# module InstanceMethods
# def whatnot
# 6
# end
# end
module ClassMethods
def whatnot
42
end
end
end
class Thing
include Stuff
end
puts Thing.new.whatnot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment