Class: Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Comment
show all
- Defined in:
- app/models/comment.rb
Defined Under Namespace
Classes: CommentNotAllowed
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.approved ⇒ Object
4
5
6
|
# File 'app/models/comment.rb', line 4
def self.approved
where :approved => true
end
|
.unapproved ⇒ Object
8
9
10
|
# File 'app/models/comment.rb', line 8
def self.unapproved
where :approved => false
end
|
Instance Method Details
#around_save ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/models/comment.rb', line 14
def around_save
if just_approved?
run_callbacks(:approve) { yield }
elsif just_unapproved?
run_callbacks(:unapprove) { yield }
else
yield
end
end
|
make sure we’re storing the base clase for STI
38
39
40
|
# File 'app/models/comment.rb', line 38
def (sType)
super(sType.to_s.classify.constantize.base_class.to_s)
end
|
#filter ⇒ Object
55
56
57
|
# File 'app/models/comment.rb', line 55
def filter
.
end
|
#just_approved? ⇒ Boolean
63
64
65
|
# File 'app/models/comment.rb', line 63
def just_approved?
approved_changed? and approved?
end
|
#just_unapproved? ⇒ Boolean
67
68
69
|
# File 'app/models/comment.rb', line 67
def just_unapproved?
approved_changed? and unapproved?
end
|
#owner ⇒ Object
51
52
53
|
# File 'app/models/comment.rb', line 51
def owner
end
|
#state_changes ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'app/models/comment.rb', line 71
def state_changes
state_changes = if just_approved?
[:approved]
elsif just_unapproved?
[:unapproved]
end || []
super + state_changes
end
|
#unapproved? ⇒ Boolean
59
60
61
|
# File 'app/models/comment.rb', line 59
def unapproved?
!approved?
end
|