Module: TheComments::Comment
- Extended by:
- ActiveSupport::Concern
- Included in:
- Comment
- Defined in:
- app/models/concerns/the_comments/comment.rb
Instance Method Summary collapse
- #avatar_url ⇒ Object
- #header_title ⇒ Object
- #mark_as_not_spam ⇒ Object
- #mark_as_spam ⇒ Object
- #to_spam ⇒ Object
- #user_name ⇒ Object
Instance Method Details
#avatar_url ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/concerns/the_comments/comment.rb', line 42 def avatar_url src = id.to_s src = title unless title.blank? src = contacts if !contacts.blank? && /@/ =~ contacts hash = Digest::MD5.hexdigest(src) "https://2.gravatar.com/avatar/#{hash}?s=42&d=https://identicons.github.com/#{hash}.png" end |
#header_title ⇒ Object
34 35 36 |
# File 'app/models/concerns/the_comments/comment.rb', line 34 def header_title title.present? ? title : I18n.t('the_comments.guest_name') end |
#mark_as_not_spam ⇒ Object
56 57 58 59 60 |
# File 'app/models/concerns/the_comments/comment.rb', line 56 def mark_as_not_spam count = self_and_descendants.update_all({spam: false}) update_spam_counter count end |
#mark_as_spam ⇒ Object
50 51 52 53 54 |
# File 'app/models/concerns/the_comments/comment.rb', line 50 def mark_as_spam count = self_and_descendants.update_all({spam: true}) update_spam_counter count end |
#to_spam ⇒ Object
62 63 64 |
# File 'app/models/concerns/the_comments/comment.rb', line 62 def to_spam mark_as_spam end |
#user_name ⇒ Object
38 39 40 |
# File 'app/models/concerns/the_comments/comment.rb', line 38 def user_name user.try(:username) || user.try(:login) || header_title end |