Class: Refinery::Blog::Comment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/refinery/blog/comment.rb

Defined Under Namespace

Modules: Moderation, Notification

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.approvedObject


21
22
23
# File 'app/models/refinery/blog/comment.rb', line 21

def approved
  where(state: 'approved')
end

.rejectedObject


25
26
27
# File 'app/models/refinery/blog/comment.rb', line 25

def rejected
  where(state: 'rejected')
end

.toggle!Object


52
53
54
55
56
57
# File 'app/models/refinery/blog/comment.rb', line 52

def self.toggle!
  currently = Refinery::Setting.find_or_set(:comments_allowed, true, {
    :scoping => 'blog'
  })
  Refinery::Setting.set(:comments_allowed, {value: !currently, scoping: 'blog'})
end

.unmoderatedObject


17
18
19
# File 'app/models/refinery/blog/comment.rb', line 17

def unmoderated
  where(state: nil)
end

Instance Method Details

#approve!Object


32
33
34
# File 'app/models/refinery/blog/comment.rb', line 32

def approve!
  self.update_column(:state, 'approved')
end

#approved?Boolean


44
45
46
# File 'app/models/refinery/blog/comment.rb', line 44

def approved?
  self.state == 'approved'
end

#reject!Object


36
37
38
# File 'app/models/refinery/blog/comment.rb', line 36

def reject!
  self.update_column(:state, 'rejected')
end

#rejected?Boolean


40
41
42
# File 'app/models/refinery/blog/comment.rb', line 40

def rejected?
  self.state == 'rejected'
end

#unmoderated?Boolean


48
49
50
# File 'app/models/refinery/blog/comment.rb', line 48

def unmoderated?
  self.state.nil?
end