Class: Ahub::Answer

Inherits:
Object
  • Object
show all
Includes:
APIResource, Deletable
Defined in:
lib/ahub/answer.rb

Instance Attribute Summary

Attributes included from APIResource

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Deletable

#delete, #undelete

Methods included from APIResource

#update

Constructor Details

#initialize(attrs) ⇒ Answer

Returns a new instance of Answer.



12
13
14
15
# File 'lib/ahub/answer.rb', line 12

def initialize(attrs)
  super
  @author = Ahub::User.new(attrs[:author])
end

Class Method Details

.create(question_id:, body:, username:, password:) ⇒ Object



6
7
8
9
10
# File 'lib/ahub/answer.rb', line 6

def self.create(question_id:, body:, username:, password:)
  url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"

  create_resource(url: url, payload: {body: body}, headers: headers(username: username, password: password))
end

Instance Method Details

#html_urlObject



21
22
23
# File 'lib/ahub/answer.rb', line 21

def html_url
  "#{Ahub::DOMAIN}/answers/#{id}/view.html" if id
end

#userObject



17
18
19
# File 'lib/ahub/answer.rb', line 17

def user
  @author
end