Class: WhatsonComment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WhatsonComment
show all
- Defined in:
- app/models/whatson_comment.rb
Defined Under Namespace
Modules: Moderation, Notification
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.toggle! ⇒ Object
55
56
57
58
59
60
|
# File 'app/models/whatson_comment.rb', line 55
def self.toggle!
currently = RefinerySetting.find_or_set(:comments_allowed, true, {
:scoping => 'whatson'
})
RefinerySetting.set(:comments_allowed, {:value => !currently, :scoping => 'whatson'})
end
|
Instance Method Details
#approve! ⇒ Object
35
36
37
|
# File 'app/models/whatson_comment.rb', line 35
def approve!
self.update_attribute(:state, 'approved')
end
|
#approved? ⇒ Boolean
47
48
49
|
# File 'app/models/whatson_comment.rb', line 47
def approved?
self.state == 'approved'
end
|
#avatar_url(options = {}) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/whatson_comment.rb', line 22
def avatar_url(options = {})
require 'digest/md5'
params = {
:s => options[:size] || 60,
:d => options[:default_image]
}
query_string = params.map do |k,v|
[k,v].map { |s| CGI::escape(s.to_s) }.join('=')
end.join('&')
email_md5 = Digest::MD5.hexdigest(self.email.to_s.strip.downcase)
"http://gravatar.com/avatar/#{email_md5}?#{query_string}"
end
|
#reject! ⇒ Object
39
40
41
|
# File 'app/models/whatson_comment.rb', line 39
def reject!
self.update_attribute(:state, 'rejected')
end
|
#rejected? ⇒ Boolean
43
44
45
|
# File 'app/models/whatson_comment.rb', line 43
def rejected?
self.state == 'rejected'
end
|
#unmoderated? ⇒ Boolean
51
52
53
|
# File 'app/models/whatson_comment.rb', line 51
def unmoderated?
self.state.nil?
end
|