commontator 0.5.13 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/lib/commontator/acts_as_commontable.rb +10 -8
- data/lib/commontator/acts_as_commontable.rb~ +43 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- metadata +2 -1
data/README.md
CHANGED
@@ -112,7 +112,7 @@ That's it! Commontator is now ready for use.
|
|
112
112
|
## Browser Support
|
113
113
|
|
114
114
|
No incompatibilities are currently known with any of the major browsers.
|
115
|
-
Currently commontator requires javascript
|
115
|
+
Currently commontator requires javascript enabled to function properly.
|
116
116
|
|
117
117
|
## Customization
|
118
118
|
|
@@ -132,6 +132,10 @@ $ rake commontator:copy:models
|
|
132
132
|
|
133
133
|
You are now free to modify them and have any changes made manifest in your application.
|
134
134
|
|
135
|
+
## Testing
|
136
|
+
|
137
|
+
Soon
|
138
|
+
|
135
139
|
## Contributing
|
136
140
|
|
137
141
|
1. Fork it
|
@@ -15,20 +15,22 @@ module Commontator
|
|
15
15
|
has_many :comments, :class_name => 'Commontator::Comment', :through => :thread
|
16
16
|
has_many :subscriptions, :class_name => 'Commontator::Subscription', :through => :thread
|
17
17
|
|
18
|
-
after_initialize :create_thread, :unless => :thread, :if => :id
|
19
|
-
before_validation :build_thread, :unless => :thread
|
20
|
-
|
21
18
|
validates_presence_of :thread
|
22
19
|
|
23
20
|
cattr_accessor :commontable_config
|
24
21
|
self.commontable_config = Commontator::CommontableConfig.new
|
25
22
|
self.is_commontable = true
|
26
23
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
alias_method :thread_raw, :thread
|
25
|
+
|
26
|
+
def thread
|
27
|
+
raw = thread_raw
|
28
|
+
return raw unless raw.nil?
|
29
|
+
return Commontator::Thread.find_or_create_by_commontable_id_and_commontable_type(self.id, self.class.name) \
|
30
|
+
unless self.id.nil?
|
31
|
+
self.thread = Commontator::Thread.new
|
32
|
+
self.thread.commontable = self
|
33
|
+
self.thread
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'commontator/commontable_config'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
module ActsAsCommontable
|
5
|
+
def self.included(base)
|
6
|
+
base.class_attribute :is_commontable
|
7
|
+
base.is_commontable = false
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def acts_as_commontable(options = {})
|
13
|
+
class_eval do
|
14
|
+
has_one :thread, :as => :commontable, :class_name => 'Commontator::Thread'
|
15
|
+
has_many :comments, :class_name => 'Commontator::Comment', :through => :thread
|
16
|
+
has_many :subscriptions, :class_name => 'Commontator::Subscription', :through => :thread
|
17
|
+
|
18
|
+
validates_presence_of :thread
|
19
|
+
|
20
|
+
cattr_accessor :commontable_config
|
21
|
+
self.commontable_config = Commontator::CommontableConfig.new
|
22
|
+
self.is_commontable = true
|
23
|
+
|
24
|
+
alias_method :thread_raw, :thread
|
25
|
+
|
26
|
+
def thread
|
27
|
+
t = thread_raw
|
28
|
+
return t unless t.nil?
|
29
|
+
return Commontator::Thread.find_or_create_by_commontable_id_and_commontable_type(self.id, self.class.name) \
|
30
|
+
unless self.id.nil?
|
31
|
+
self.thread = Commontator::Thread.new
|
32
|
+
self.thread.commontable = self
|
33
|
+
self.thread
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
alias_method :acts_as_commentable, :acts_as_commontable
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
ActiveRecord::Base.send :include, Commontator::ActsAsCommontable
|
data/lib/commontator/version.rb
CHANGED
data/lib/commontator/version.rb~
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commontator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/commontator/version.rb
|
132
132
|
- lib/commontator/engine.rb
|
133
133
|
- lib/commontator/shared_methods.rb~
|
134
|
+
- lib/commontator/acts_as_commontable.rb~
|
134
135
|
- lib/commontator/shared_helper.rb~
|
135
136
|
- lib/commontator/commontable_config.rb
|
136
137
|
- lib/commontator/version.rb~
|