Sha256: 3ace1cb8c802f4624f36a68592340c94c9d8e3660ade68e1a07e2b6c3aa5c1fc

Contents?: true

Size: 1008 Bytes

Versions: 5

Compression:

Stored size: 1008 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
          has_many :comments, :as => :commontator, :class_name => 'Commontator::Comment'

          has_many :subscriptions, :as => :subscriber, :class_name => 'Commontator::Subscription', :dependent => :destroy
          
          cattr_accessor :commontator_config
          self.commontator_config = Commontator::CommontatorConfig.new(options)
          self.is_commontator = true
        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

5 entries across 5 versions & 1 rubygems

Version Path
commontator-2.0.2 lib/commontator/acts_as_commontator.rb~
commontator-4.0.1 lib/commontator/acts_as_commontator.rb~
commontator-4.0.0 lib/commontator/acts_as_commontator.rb~
commontator-2.0.1 lib/commontator/acts_as_commontator.rb~
commontator-2.0.0 lib/commontator/acts_as_commontator.rb~