Method: Tinybucket::Model::Comment#parent

Defined in:
lib/tinybucket/model/comment.rb

#parentHash

Returns:

  • (Hash)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tinybucket/model/comment.rb', line 30

class Comment < Base
  include Tinybucket::Model::Concerns::RepositoryKeys

  acceptable_attributes \
    :links, :id, :parent, :filename, :content, :user, :inline, \
    :created_on, :updated_on, :uuid

  # @!attribute [rw] commented_to
  #   @return [Tinybucket::Model::PullRequest, Tinybucket::Model::Commit]
  attr_accessor :commented_to

  private

  def commit_api
    create_api('Comments', repo_keys)
  end

  def pull_request_api
    create_api('PullRequests', repo_keys)
  end

  def load_model
    api =
      case commented_to
      when Tinybucket::Model::Commit
        commit_api
      when Tinybucket::Model::PullRequest
        pull_request_api
      else
        raise ArgumentError, 'commented_to was invalid'
      end

    api.commented_to = commented_ato
    api.find(id, {})
  end
end