Class: Ahub::Answer

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIResource

#destroy, #update

Constructor Details

#initialize(attrs) ⇒ Answer

Returns a new instance of Answer.



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

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

Class Method Details

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



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

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

#userObject



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

def user
  @author
end