make_commentable 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,30 @@
|
|
1
|
-
require 'version'
|
2
1
|
require 'active_record'
|
3
2
|
|
4
|
-
module
|
3
|
+
module MakeCommentable
|
4
|
+
module Commentable
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.included(base)
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
module ClassMethods
|
11
|
+
def mark_as_commentable(options={})
|
12
|
+
has_many :comments, {:as => :commentable, :dependent => :destroy}.merge(options)
|
13
|
+
accepts_nested_attributes_for :comments, :allow_destroy => true
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
include Commentable::InstanceMethods
|
16
|
+
extend Commentable::SingletonMethods
|
17
|
+
end
|
17
18
|
end
|
18
|
-
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
#This module contains class methods
|
21
|
+
module SingletonMethods
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
# This module contains instance methods
|
25
|
+
module InstanceMethods
|
26
|
+
end
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
28
30
|
ActiveRecord::Base.send(:include, Commentable)
|