begin29
11/8/2016 - 12:50 PM

From http://www.fakingfantastic.com/2010/09/20/concerning-yourself-with-active-support-concern/ Put instance methods inside module and inclu

From http://www.fakingfantastic.com/2010/09/20/concerning-yourself-with-active-support-concern/ Put instance methods inside module and include it to class

module TagLib
  
  module ClassMethods
    def find_by_tags()
      # ...
    end
  end
 
  module InstanceMethods
    def tags()
      # ...
    end
  end
 
  def self.included(base)
    base.send :include, InstanceMethods
    base.send :extend, ClassMethods
  end
 
end

class ActiveRecord::Base
  include TagLib
end
module TagLib
  extend ActiveSupport::Concern

  module ClassMethods
    def find_by_tags()
      # ...
    end
  end
 
  module InstanceMethods
    def tags()
      # ...
    end
  end 
end

class ActiveRecord::Base
  include TagLib
end