Sha256: 7c41dd5842367cfa00c84015897116e4078a65c1bd8e5cf2786cd06b61b019a2

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 Bytes

Contents

require 'commontator/commontator_config'

module Commontator
  module ActsAsCommontator
    def self.included(base)
      base.class_attribute :is_commontator
      base.is_commontator = false
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      def acts_as_commontator(options = {})
        class_eval do
          cattr_accessor :commontator_config
          self.commontator_config = Commontator::CommontatorConfig.new(options)
          self.is_commontator = true

          has_many :comments, :as => :creator, :class_name => 'Commontator::Comment'

          has_many :subscriptions, :as => :subscriber, :class_name => 'Commontator::Subscription', :dependent => :destroy
        end
      end
      
      alias_method :acts_as_commonter, :acts_as_commontator
      alias_method :acts_as_commentator, :acts_as_commontator
      alias_method :acts_as_commenter, :acts_as_commontator
    end
  end
end

ActiveRecord::Base.send :include, Commontator::ActsAsCommontator

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.8.0 lib/commontator/acts_as_commontator.rb
commontator-4.7.2 lib/commontator/acts_as_commontator.rb
commontator-4.7.1 lib/commontator/acts_as_commontator.rb
commontator-4.7.0 lib/commontator/acts_as_commontator.rb
commontator-4.6.1 lib/commontator/acts_as_commontator.rb
commontator-4.6.0 lib/commontator/acts_as_commontator.rb