Sha256: eda2c53a295b53aa6edd97f3c8d651741a5ee6aaad9de6e85bff8353140bc3dc
Contents?: true
Size: 882 Bytes
Versions: 2
Compression:
Stored size: 882 Bytes
Contents
require 'commontator/commontable_config' module Commontator module ActsAsCommontable def self.included(base) base.class_attribute :is_commontable base.is_commontable = false base.extend(ClassMethods) end module ClassMethods def acts_as_commontable(options = {}) class_eval do cattr_accessor :commontable_config self.commontable_config = Commontator::CommontableConfig.new(options) self.is_commontable = true has_one :thread, :as => :commontable, :class_name => 'Commontator::Thread' validates_presence_of :thread before_validation :build_thread, :unless => :thread end end alias_method :acts_as_commentable, :acts_as_commontable end end end ActiveRecord::Base.send :include, Commontator::ActsAsCommontable
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
commontator-4.10.1 | lib/commontator/acts_as_commontable.rb |
commontator-4.10.0 | lib/commontator/acts_as_commontable.rb |