Module: Redd::Models::Moderatable

Included in:
Comment, Submission
Defined in:
lib/redd/models/moderatable.rb

Overview

A model that can be managed by a moderator (i.e. Submissions and Comments).

Instance Method Summary collapse

Instance Method Details

#approveObject

Approve a submission.


8
9
10
# File 'lib/redd/models/moderatable.rb', line 8

def approve
  client.post('/api/approve', id: read_attribute(:name))
end

#distinguish(how = :yes) ⇒ Object

Note:

:sticky is for comments. see Submission#make_sticky for posts.

Distinguish a link or comment with a sigil to show that it has been created by a moderator.

Parameters:

  • how (:yes, :no, :admin, :special, :sticky) (defaults to: :yes)

    how to distinguish the thing


21
22
23
24
25
26
27
28
# File 'lib/redd/models/moderatable.rb', line 21

def distinguish(how = :yes)
  params = { id: read_attribute(:name), how: how }
  if how == :sticky
    params[:how] = :yes
    params[:sticky] = true
  end
  client.post('/api/distinguish', params)
end

#ignore_reportsObject

Stop getting any moderator-related reports on the thing.


36
37
38
# File 'lib/redd/models/moderatable.rb', line 36

def ignore_reports
  client.post('/api/ignore_reports', id: read_attribute(:name))
end

#remove(spam: false) ⇒ Object

Remove a submission.

Parameters:

  • spam (Boolean) (defaults to: false)

    whether or not this item is removed due to it being spam


14
15
16
# File 'lib/redd/models/moderatable.rb', line 14

def remove(spam: false)
  client.post('/api/remove', id: read_attribute(:name), spam: spam)
end

#undistinguishObject

Remove the sigil that shows a thing was created by a moderator.


31
32
33
# File 'lib/redd/models/moderatable.rb', line 31

def undistinguish
  distinguish(:no)
end

#unignore_reportsObject

Start getting moderator-related reports on the thing again.


41
42
43
# File 'lib/redd/models/moderatable.rb', line 41

def unignore_reports
  client.post('/api/unignore_reports', id: read_attribute(:name))
end