Sha256: 06747fb1f6d5984075dc56c23f17f7ac84ccf295a19f0e0083023e5e0bc4b45d

Contents?: true

Size: 989 Bytes

Versions: 5

Compression:

Stored size: 989 Bytes

Contents

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', :dependent => :destroy
          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-0.4.1 lib/commontator/acts_as_commontator.rb~
commontator-0.3.10 lib/commontator/acts_as_commontator.rb
commontator-0.2.4 lib/commontator/acts_as_commontator.rb
commontator-0.2.0 lib/commontator/acts_as_commontator.rb
commontator-0.1.46 lib/commontator/acts_as_commontator.rb