Sha256: f85fa7bdf02904c0a444d8a31f6688a266bd9c91c17523695a31a601ecb54029

Contents?: true

Size: 634 Bytes

Versions: 13

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

module Talkie
  module ActsAsCommentable
    extend ActiveSupport::Concern

    module InstanceMethods
      def root_parents
        comments.where(parent_id: nil)
      end
    end

    module ClassMethods
      def acts_as_commentable
        has_many :comments, as: :commentable,
                            class_name: "Talkie::Comment",
                            inverse_of: :commentable

        include Talkie::ActsAsCommentable::InstanceMethods
      end

      alias_method :is_commentable, :acts_as_commentable
    end
  end
end

ActiveRecord::Base.send :include, Talkie::ActsAsCommentable

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
talkie-0.5.1 lib/talkie/acts_as_commentable.rb
talkie-0.5.0 lib/talkie/acts_as_commentable.rb
talkie-0.4.1 lib/talkie/acts_as_commentable.rb
talkie-0.4.0 lib/talkie/acts_as_commentable.rb
talkie-0.3.5 lib/talkie/acts_as_commentable.rb
talkie-0.3.4 lib/talkie/acts_as_commentable.rb
talkie-0.3.3 lib/talkie/acts_as_commentable.rb
talkie-0.3.2 lib/talkie/acts_as_commentable.rb
talkie-0.3.1 lib/talkie/acts_as_commentable.rb
talkie-0.3.0 lib/talkie/acts_as_commentable.rb
talkie-0.2.0 lib/talkie/acts_as_commentable.rb
talkie-0.1.1 lib/talkie/acts_as_commentable.rb
talkie-0.1.0 lib/talkie/acts_as_commentable.rb