jackdempsey / acts_as_commentable

The ActiveRecord acts_as_commentable plugin
http://juixe.com/svn/acts_as_commentable/
MIT License
834 stars 178 forks source link

Refactored Juixe::Acts::Commentable a bit #63

Open mikecmpbll opened 9 years ago

mikecmpbll commented 9 years ago

Just a small tidy up that I thought I'd pass on. Juixe::Acts::Commentable was being included in AR::Base with a ClassMethods module, and this ClassMethods module was being extended on AR::Base when the Commentable module was included:

module Commentable
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    # ...
  end
end

ActiveRecord::Base.send(:include, Commentable)

This is unnecessary indirection because you can just extend the module in the first place and do away with the ClassMethods module and the self.included method, a la:

module Commentable
  # ...
end

ActiveRecord::Base.send(:extend, Commentable)

I also couldn't get the test suite running with Ruby 2.1.1 out of the box, so I've included what was necessary for me to get the suite green, which was: