Sha256: 5ca7ca8a581efd329ff0b38a8f0ec9b010a3bdd1bba46a34da6c8321c559d31f

Contents?: true

Size: 569 Bytes

Versions: 8

Compression:

Stored size: 569 Bytes

Contents

module Ahub
  class Answer
    include Ahub::APIResource
    include Ahub::Deletable

    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

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

    def user
      @author
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ahub-0.12.0 lib/ahub/answer.rb
ahub-0.11.5 lib/ahub/answer.rb
ahub-0.11.4 lib/ahub/answer.rb
ahub-0.11.3 lib/ahub/answer.rb
ahub-0.11.2 lib/ahub/answer.rb
ahub-0.11.1 lib/ahub/answer.rb
ahub-0.11.0 lib/ahub/answer.rb
ahub-0.10.0 lib/ahub/answer.rb