Class: Enki::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Enki::Comment
show all
- Extended by:
- PaginationShim
- Defined in:
- app/models/enki/comment.rb
Constant Summary
collapse
- DEFAULT_LIMIT =
15
Class Method Summary
collapse
Instance Method Summary
collapse
paginated, paginated_pages
Class Method Details
.build_for_preview(params) ⇒ Object
63
64
65
|
# File 'app/models/enki/comment.rb', line 63
def build_for_preview(params)
Comment.new_with_filter(params)
end
|
.find_recent(options = {}) ⇒ Object
67
68
69
70
71
72
|
# File 'app/models/enki/comment.rb', line 67
def find_recent(options = {})
find(:all, {
:limit => DEFAULT_LIMIT,
:order => 'created_at DESC'
}.merge(options))
end
|
.new_with_filter(params) ⇒ Object
56
57
58
59
60
61
|
# File 'app/models/enki/comment.rb', line 56
def new_with_filter(params)
= Comment.new(params)
.created_at = Time.now
.apply_filter
end
|
.protected_attribute?(attribute) ⇒ Boolean
52
53
54
|
# File 'app/models/enki/comment.rb', line 52
def protected_attribute?(attribute)
[:author, :body].include?(attribute.to_sym)
end
|
Instance Method Details
#apply_filter ⇒ Object
17
18
19
|
# File 'app/models/enki/comment.rb', line 17
def apply_filter
self.body_html = Lesstile.format_as_xhtml(self.body, :code_formatter => Lesstile::CodeRayFormatter)
end
|
#approved? ⇒ Boolean
29
30
31
|
# File 'app/models/enki/comment.rb', line 29
def approved?
true
end
|
#denormalize ⇒ Object
33
34
35
|
# File 'app/models/enki/comment.rb', line 33
def denormalize
self.post.
end
|
#destroy_with_undo ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'app/models/enki/comment.rb', line 37
def destroy_with_undo
undo_item = nil
transaction do
self.destroy
undo_item = DeleteCommentUndo.create_undo(self)
end
undo_item
end
|
#post_title ⇒ Object
47
48
49
|
# File 'app/models/enki/comment.rb', line 47
def post_title
post.title
end
|
#trusted_user? ⇒ Boolean
21
22
23
|
# File 'app/models/enki/comment.rb', line 21
def trusted_user?
false
end
|
#user_logged_in? ⇒ Boolean
25
26
27
|
# File 'app/models/enki/comment.rb', line 25
def user_logged_in?
false
end
|