Class: Redd::Models::LiveThread
- Inherits:
-
LazyModel
- Object
- BasicModel
- LazyModel
- Redd::Models::LiveThread
- Defined in:
- lib/redd/models/live_thread.rb
Overview
Represents a live thread.
Defined Under Namespace
Classes: LiveUpdate
Instance Attribute Summary
Attributes inherited from BasicModel
Class Method Summary collapse
-
.from_id(client, id) ⇒ LiveThread
Get a LiveThread from its id.
Instance Method Summary collapse
-
#configure(**params) ⇒ Object
Configure the settings of this live thread.
-
#contributors ⇒ Array<User>
The contributors to this thread.
-
#discussions(**params) ⇒ Listing<Submission>
Returns all discussions that link to this live thread.
-
#invited_contributors ⇒ Array<User>
Users invited to contribute to this thread.
-
#update(body) ⇒ Object
Add an update to this live event.
-
#updates(**params) ⇒ Listing
Get the updates from the thread.
Methods inherited from LazyModel
#force_load, #initialize, #method_missing, #respond_to_missing?, #to_h
Methods inherited from BasicModel
#initialize, #inspect, #method_missing, #respond_to_missing?, #to_ary, #to_h
Constructor Details
This class inherits a constructor from Redd::Models::LazyModel
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Redd::Models::LazyModel
Class Method Details
.from_id(client, id) ⇒ LiveThread
Get a LiveThread from its id.
16 17 18 |
# File 'lib/redd/models/live_thread.rb', line 16 def self.from_id(client, id) new(client, id: id) end |
Instance Method Details
#configure(**params) ⇒ Object
Configure the settings of this live thread
37 38 39 |
# File 'lib/redd/models/live_thread.rb', line 37 def configure(**params) @client.post("/api/live/#{get_attribute(:id)}/edit", params) end |
#contributors ⇒ Array<User>
Returns the contributors to this thread.
48 49 50 51 52 |
# File 'lib/redd/models/live_thread.rb', line 48 def contributors @client.get("/live/#{get_attribute(:id)}/contributors").body[0][:data].map do |user| User.new(@client, user) end end |
#discussions(**params) ⇒ Listing<Submission>
Returns all discussions that link to this live thread.
69 70 71 |
# File 'lib/redd/models/live_thread.rb', line 69 def discussions(**params) @client.model(:get, "/live/#{get_attribute(:id)}/discussions", params) end |
#invited_contributors ⇒ Array<User>
Returns users invited to contribute to this thread.
55 56 57 58 59 |
# File 'lib/redd/models/live_thread.rb', line 55 def invited_contributors @client.get("/live/#{get_attribute(:id)}/contributors").body[1][:data].map do |user| User.new(@client, user) end end |
#update(body) ⇒ Object
Add an update to this live event.
43 44 45 |
# File 'lib/redd/models/live_thread.rb', line 43 def update(body) @client.post("/api/live/#{get_attribute(:id)}/update", body: body) end |
#updates(**params) ⇒ Listing
Get the updates from the thread.
27 28 29 |
# File 'lib/redd/models/live_thread.rb', line 27 def updates(**params) @client.model(:get, "/live/#{get_attribute(:id)}", params) end |