Class: CamaleonCms::PostCommentDecorator
- Inherits:
-
Draper::Decorator
- Object
- Draper::Decorator
- CamaleonCms::PostCommentDecorator
- Defined in:
- app/decorators/camaleon_cms/post_comment_decorator.rb
Instance Method Summary collapse
- #the_answers ⇒ Object
- #the_author_email ⇒ Object
- #the_author_name ⇒ Object
-
#the_author_url ⇒ Object
A missing user reads the same as the anonymous one: there is no profile to link to.
- #the_content ⇒ Object
-
#the_created_at(format = :long) ⇒ Object
return created at date formatted.
- #the_post ⇒ Object
-
#the_user ⇒ Object
(also: #the_author)
return owner of this comment, or nil for rows whose user is missing.
Instance Method Details
#the_answers ⇒ Object
24 25 26 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 24 def the_answers object.children.approveds end |
#the_author_email ⇒ Object
34 35 36 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 34 def object..presence || object.user&.email end |
#the_author_name ⇒ Object
28 29 30 31 32 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 28 def # `fullname` is the model method; `full_name` never existed, so this fallback # crashed for any comment stored without an author string. object..presence || object.user&.fullname end |
#the_author_url ⇒ Object
A missing user reads the same as the anonymous one: there is no profile to link to. Its three siblings above were made nil-safe for orphaned rows; this one was missed, so it still raised NoMethodError on exactly the rows they were fixed to tolerate.
41 42 43 44 45 46 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 41 def return object. if object..present? return '' if object.user.blank? || object.user.username == 'anonymous' object.user.decorate.the_url end |
#the_content ⇒ Object
20 21 22 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 20 def the_content object.content end |
#the_created_at(format = :long) ⇒ Object
return created at date formatted
6 7 8 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 6 def the_created_at(format = :long) h.l(object.created_at, format: format.to_sym) end |
#the_post ⇒ Object
16 17 18 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 16 def the_post object.post.decorate end |
#the_user ⇒ Object Also known as:
return owner of this comment, or nil for rows whose user is missing
11 12 13 |
# File 'app/decorators/camaleon_cms/post_comment_decorator.rb', line 11 def the_user object.user&.decorate end |