summaryrefslogtreecommitdiff
path: root/lib/github/representation/issuable.rb
blob: 768ba3b993c7b6923239d3df491eb0ba5992595b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Github
  module Representation
    class Issuable < Representation::Base
      def iid
        raw['number']
      end

      def title
        raw['title']
      end

      def description
        raw['body'] || ''
      end

      def milestone
        return unless raw['milestone'].present?

        @milestone ||= Github::Representation::Milestone.new(raw['milestone'])
      end

      def author
        @author ||= Github::Representation::User.new(raw['user'], options)
      end

      def labels?
        raw['labels'].any?
      end

      def labels
        @labels ||= Array(raw['labels']).map do |label|
          Github::Representation::Label.new(label, options)
        end
      end
    end
  end
end