Sha256: 308c7f99aabefe60d48e06175aa85490bb1513de55c7ae6bc5919ebf02734c24

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

require 'parole/version'

require 'active_record'
require 'active_support'

require 'parole/commentable'
require 'parole/comment'

class ActiveRecord::Base
  def self.acts_as_commentable(options = {})
    Parole.commentable_classes << self

    class_attribute :commentable_options, :acts_as_commentable
    self.acts_as_commentable = true
    self.commentable_options = options.reverse_merge(roles: [])
    self.commentable_options[:roles] = commentable_options[:roles].map(&:to_s)

    include Parole::Commentable
  end

  def self.acts_as_commentable?
    !!self.acts_as_commentable
  end

  def self.acts_as_comment(*args)
    include Parole::Comment
  end
end

module Parole
  def self.commentable_classes
    @commentable_classes ||= []
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parole-0.1.2 lib/parole.rb
parole-0.1.1 lib/parole.rb