Sha256: 7ee5b8cf98717ae2edd4766238ef81e9bd7dc723ed08d927e25271d9d885e4b5

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

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

8 entries across 8 versions & 1 rubygems

Version Path
commontator-4.11.1 lib/commontator/acts_as_commontator.rb
commontator-4.11.0 lib/commontator/acts_as_commontator.rb
commontator-4.10.5 lib/commontator/acts_as_commontator.rb
commontator-4.10.4 lib/commontator/acts_as_commontator.rb
commontator-4.10.3 lib/commontator/acts_as_commontator.rb
commontator-4.10.2 lib/commontator/acts_as_commontator.rb
commontator-4.10.1 lib/commontator/acts_as_commontator.rb
commontator-4.10.0 lib/commontator/acts_as_commontator.rb