Module: Redd::Models::Postable
- Included in:
- Comment, Submission
- Defined in:
- lib/redd/models/postable.rb
Overview
Methods for user-submitted content, i.e. Submissions and Comments.
Instance Method Summary collapse
-
#delete ⇒ Object
Delete the thing.
-
#disable_inbox_replies ⇒ Object
Stop sending replies to this thing to the user’s inbox.
-
#downvote ⇒ Object
Downvote the model.
-
#edit(text) ⇒ self
Edit a thing.
-
#enable_inbox_replies ⇒ Object
Send replies to this thing to the user’s inbox.
-
#hide ⇒ Object
Hide a link from the user.
-
#save(category = nil) ⇒ Object
Save a link or comment to the user’s account.
-
#undo_vote ⇒ Object
Clear any upvotes or downvotes on the model.
-
#unhide ⇒ Object
Unhide a previously hidden link.
-
#unsave ⇒ Object
Remove the link or comment from the user’s saved links.
-
#upvote ⇒ Object
Upvote the model.
Instance Method Details
#delete ⇒ Object
Delete the thing.
17 18 19 |
# File 'lib/redd/models/postable.rb', line 17 def delete @client.post('/api/del', id: get_attribute(:name)) end |
#disable_inbox_replies ⇒ Object
Stop sending replies to this thing to the user’s inbox.
65 66 67 |
# File 'lib/redd/models/postable.rb', line 65 def disable_inbox_replies @client.post('/api/sendreplies', id: get_attribute(:name), state: false) end |
#downvote ⇒ Object
Downvote the model.
50 51 52 |
# File 'lib/redd/models/postable.rb', line 50 def downvote vote(-1) end |
#edit(text) ⇒ self
Edit a thing.
10 11 12 13 14 |
# File 'lib/redd/models/postable.rb', line 10 def edit(text) @client.post('/api/editusertext', thing_id: get_attribute(:name), text: text) @attributes[is_a?(Submission) ? :selftext : :body] = text self end |
#enable_inbox_replies ⇒ Object
Send replies to this thing to the user’s inbox.
60 61 62 |
# File 'lib/redd/models/postable.rb', line 60 def enable_inbox_replies @client.post('/api/sendreplies', id: get_attribute(:name), state: true) end |
#hide ⇒ Object
Hide a link from the user.
35 36 37 |
# File 'lib/redd/models/postable.rb', line 35 def hide @client.post('/api/hide', id: get_attribute(:name)) end |
#save(category = nil) ⇒ Object
Save a link or comment to the user’s account.
23 24 25 26 27 |
# File 'lib/redd/models/postable.rb', line 23 def save(category = nil) params = { id: get_attribute(:name) } params[:category] = category if category @client.post('/api/save', params) end |
#undo_vote ⇒ Object
Clear any upvotes or downvotes on the model.
55 56 57 |
# File 'lib/redd/models/postable.rb', line 55 def undo_vote vote(0) end |
#unhide ⇒ Object
Unhide a previously hidden link.
40 41 42 |
# File 'lib/redd/models/postable.rb', line 40 def unhide @client.post('/api/unhide', id: get_attribute(:name)) end |
#unsave ⇒ Object
Remove the link or comment from the user’s saved links.
30 31 32 |
# File 'lib/redd/models/postable.rb', line 30 def unsave @client.post('/api/unsave', id: get_attribute(:name)) end |
#upvote ⇒ Object
Upvote the model.
45 46 47 |
# File 'lib/redd/models/postable.rb', line 45 def upvote vote(1) end |