Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.

Commit

Permalink
added a few more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Van Horn committed Dec 3, 2008
1 parent d6e1b8c commit e9e0e10
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/disqus/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(id, username, display_name, url, email_hash, has_avatar)
@id, @username, @display_name, @url, @email_hash, @has_avatar = id, username, display_name, url, email_hash, has_avatar
end

# returns the user's <tt>display_name</tt> or <tt>username</tt> if <tt>display_name</tt> is blank.
def name
@display_name.blank? ? @username : @display_name
end
Expand Down
5 changes: 4 additions & 1 deletion lib/disqus/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def initialize(id, forum, thread, created_at, message, parent_post, shown, is_an
@id, @forum, @thread, @created_at, @message, @parent_post, @shown, @is_anonymous, @author = id.to_i, forum, thread, Time.parse(created_at.to_s), message, parent_post, shown, is_anonymous, author
end

# Returns an array of Post objects representing all posts belonging to the given thread. The arrays is sorted in order of created_at date.
def self.list(thread)
response = Disqus::Api::get_thread_posts(:thread_id =>thread.id, :forum_api_key => thread.forum.key)
if response["succeeded"]
Expand Down Expand Up @@ -38,4 +39,6 @@ def self.list(thread)
end
end
end
end
end


10 changes: 10 additions & 0 deletions lib/disqus/thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def initialize(id, forum, slug, title, created_at, allow_comments, url, identifi
@posts = []
end

# Threads are equal if all their attributes are equal.
def ==(other_thread)
id == other_thread.id &&
forum == other_thread.forum &&
Expand All @@ -19,6 +20,7 @@ def ==(other_thread)
identifier == other_thread.identifier
end

# returns an array of Thread objects representing the threads belonging to the given Forum.
def self.list(forum, opts = {})
response = Disqus::Api::get_thread_list(opts.merge(:forum_id =>forum.id, :forum_api_key => forum.key))
if response["succeeded"]
Expand All @@ -43,6 +45,14 @@ def posts(force_update = false)
@posts
end

# Sets the provided values on the thread object.
#
# options:
# * :thread_id
# * :title
# * :slug
# * :url
# * :allow_comments
def update(opts = {})
result = Disqus::Api::update_thread(opts.merge( :forum_api_key => forum.key,
:thread_id => id,
Expand Down

0 comments on commit e9e0e10

Please sign in to comment.