Class: Disqus::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_disqusable/post.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Post

Returns a new instance of Post.



4
5
6
# File 'lib/acts_as_disqusable/post.rb', line 4

def initialize(data)
  data.each { |k, v| send(:"#{k}=", v) }
end

Instance Attribute Details

#anonymous_authorObject

Returns the value of attribute anonymous_author.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def anonymous_author
  @anonymous_author
end

#authorObject

Returns the value of attribute author.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def author
  @author
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def created_at
  @created_at
end

#forumObject

Returns the value of attribute forum.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def forum
  @forum
end

#has_been_moderatedObject

Returns the value of attribute has_been_moderated.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def has_been_moderated
  @has_been_moderated
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def id
  @id
end

#ip_addressObject

Returns the value of attribute ip_address.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def ip_address
  @ip_address
end

#is_anonymousObject

Returns the value of attribute is_anonymous.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def is_anonymous
  @is_anonymous
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def message
  @message
end

#parent_postObject

Returns the value of attribute parent_post.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def parent_post
  @parent_post
end

#pointsObject

Returns the value of attribute points.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def points
  @points
end

#shownObject

Returns the value of attribute shown.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def shown
  @shown
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def status
  @status
end

#threadObject

Returns the value of attribute thread.



3
4
5
# File 'lib/acts_as_disqusable/post.rb', line 3

def thread
  @thread
end

Class Method Details

.create(opts = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/acts_as_disqusable/post.rb', line 20

def self.create(opts={})
  response = self.class.post('/create_post', :query => opts)
  if response["success"]
    Disqus::Post.new(response["message"])
  else
    nil
  end
end

Instance Method Details

#author_nameObject



8
9
10
11
12
13
14
# File 'lib/acts_as_disqusable/post.rb', line 8

def author_name
  if is_anonymous
    anonymous_author["name"]
  else
    author["display_name"] || author["username"]
  end
end

#linked_author(opts = {}) ⇒ Object



16
17
18
# File 'lib/acts_as_disqusable/post.rb', line 16

def linked_author(opts={})
  "<a href=\"#{author['url']}\" target=\"#{opts[:target]}\" class=\"#{opts[:class]}\">#{self.author_name}</a>"
end