Module: TheComments::Comment

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

Instance Method Summary collapse

Instance Method Details

#avatar_urlObject



31
32
33
34
35
36
37
# File 'app/models/concerns/comment.rb', line 31

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

#mark_as_not_spamObject



45
46
47
48
49
# File 'app/models/concerns/comment.rb', line 45

def mark_as_not_spam
  count = self_and_descendants.update_all({spam: false})
  update_spam_counter
  count
end

#mark_as_spamObject



39
40
41
42
43
# File 'app/models/concerns/comment.rb', line 39

def mark_as_spam
  count = self_and_descendants.update_all({spam: true})
  update_spam_counter
  count
end

#to_spamObject



51
52
53
# File 'app/models/concerns/comment.rb', line 51

def to_spam
  mark_as_spam
end