Module: TheComments::Comment

Extended by:
ActiveSupport::Concern
Included in:
Comment
Defined in:
app/models/concerns/the_comments/comment.rb

Instance Method Summary collapse

Instance Method Details

#avatar_urlObject



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_titleObject



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_spamObject



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_spamObject



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_spamObject



62
63
64
# File 'app/models/concerns/the_comments/comment.rb', line 62

def to_spam
  mark_as_spam
end

#user_nameObject



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