12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/commontator/acts_as_commontable.rb', line 12
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
def thread_with_commontator
@thread ||= thread_without_commontator
return @thread unless @thread.nil?
@thread = build_thread
@thread.save if persisted?
@thread
end
alias_method_chain :thread, :commontator
end
end
|