Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikecmpbll
Copy link

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:

  • Add test-unit to development gems
  • Change Rails.version.first to Rails::VERSION::MAJOR because String#first is a ActiveSupport extension
  • Added require 'rails/version' to be able to get Rails::VERSION ...

- Juixe::Acts::Commentable was being included in AR::Base. It had
  a ClassMethods module which was being extended on AR::Base when
  the Commentable module was included. This is pointless
  indirection and we may aswell just extend the module instead of
  including it in the first place! :)
- Added TestUnit to development gems and fixed Rails.version check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant