Class: Disqus::Thread
- Inherits:
-
Object
- Object
- Disqus::Thread
- Defined in:
- lib/acts_as_disqusable/thread.rb
Instance Attribute Summary collapse
-
#allow_comments ⇒ Object
Returns the value of attribute allow_comments.
-
#category ⇒ Object
Returns the value of attribute category.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#forum ⇒ Object
Returns the value of attribute forum.
-
#hidden ⇒ Object
Returns the value of attribute hidden.
-
#id ⇒ Object
Returns the value of attribute id.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .find_or_create(title, identifier) ⇒ Object
-
.posts(thread_id, opts = {:exclude => 'spam'}) ⇒ Object
Returns an array of posts belonging to this thread.
Instance Method Summary collapse
-
#initialize(data) ⇒ Thread
constructor
A new instance of Thread.
- #posts(opts = {:exclude => 'spam'}) ⇒ Object
- #posts_count ⇒ Object
-
#update(opts = {}) ⇒ Object
Sets the provided values on the thread object.
Constructor Details
#initialize(data) ⇒ Thread
Returns a new instance of Thread.
4 5 6 |
# File 'lib/acts_as_disqusable/thread.rb', line 4 def initialize(data) data.each { |k, v| send(:"#{k}=", v) } end |
Instance Attribute Details
#allow_comments ⇒ Object
Returns the value of attribute allow_comments.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def allow_comments @allow_comments end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def category @category end |
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def created_at @created_at end |
#forum ⇒ Object
Returns the value of attribute forum.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def forum @forum end |
#hidden ⇒ Object
Returns the value of attribute hidden.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def hidden @hidden end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def id @id end |
#identifier ⇒ Object
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def identifier @identifier end |
#slug ⇒ Object
Returns the value of attribute slug.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def slug @slug end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/acts_as_disqusable/thread.rb', line 3 def url @url end |
Class Method Details
.find_or_create(title, identifier) ⇒ Object
8 9 10 11 |
# File 'lib/acts_as_disqusable/thread.rb', line 8 def self.find_or_create(title, identifier) response = self.post('/thread_by_identifier', :body => { :title => title, :identifier => identifier }.merge(self.default_params)) Disqus::Thread.new(response["message"]["thread"]) end |
.posts(thread_id, opts = {:exclude => 'spam'}) ⇒ Object
Returns an array of posts belonging to this thread. limit — Number of entries that should be included in the response. Default is 25. start — Starting point for the query. Default is 0. filter — Type of entries that should be returned (new, spam or killed). exclude — Type of entries that should be excluded from the response (new, spam or killed).
23 24 25 26 |
# File 'lib/acts_as_disqusable/thread.rb', line 23 def self.posts(thread_id, opts={:exclude => 'spam'}) response = self.get('/get_thread_posts', :query => opts.merge(:thread_id => thread_id )) response["message"].map { |data| Disqus::Post.new(data) } end |
Instance Method Details
#posts(opts = {:exclude => 'spam'}) ⇒ Object
28 29 30 |
# File 'lib/acts_as_disqusable/thread.rb', line 28 def posts(opts={:exclude => 'spam'}) self.class.posts(self.id) end |
#posts_count ⇒ Object
13 14 15 16 |
# File 'lib/acts_as_disqusable/thread.rb', line 13 def posts_count response = self.class.get('/get_num_posts', :query => { :thread_ids => id }) response["message"][id].first.to_i end |
#update(opts = {}) ⇒ Object
Sets the provided values on the thread object.
33 34 35 36 |
# File 'lib/acts_as_disqusable/thread.rb', line 33 def update(opts = {}) result = self.class.post('/update_thread', :query => opts.merge(:forum_api_key => forum.key)) return result["succeeded"] end |