Sha256: aa9ad5cb07cf059941cd4d00cbfd9218134ab75a61a27782420b58bfd5231f81

Contents?: true

Size: 428 Bytes

Versions: 83

Compression:

Stored size: 428 Bytes

Contents

module Tenon
  module CanHaveComments
    def self.included(mod)
      mod.extend(ClassMethods)
    end

    module ClassMethods
      def can_have_comments
        send(:has_many, :comments, as: :commentable, dependent: :destroy)
        send(:has_many, :subscribers, class_name: 'CommentSubscriber', as: :commentable, dependent: :destroy)
      end
    end
  end
end

ActiveRecord::Base.send(:include, Tenon::CanHaveComments)

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
tenon-1.0.2 lib/tenon/can_have_comments.rb
tenon-1.0.1 lib/tenon/can_have_comments.rb
tenon-1.0 lib/tenon/can_have_comments.rb