BigW Consortium Gitlab

milestone_formatter.rb 860 Bytes
Newer Older
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 38 39 40 41 42 43 44 45 46 47 48
module Gitlab
  module GithubImport
    class MilestoneFormatter < BaseFormatter
      def attributes
        {
          iid: number,
          project: project,
          title: title,
          description: description,
          due_date: due_date,
          state: state,
          created_at: created_at,
          updated_at: updated_at
        }
      end

      private

      def number
        raw_data.number
      end

      def title
        raw_data.title
      end

      def description
        raw_data.description
      end

      def due_date
        raw_data.due_on
      end

      def state
        raw_data.state == 'closed' ? 'closed' : 'active'
      end

      def created_at
        raw_data.created_at
      end

      def updated_at
        state == 'closed' ? raw_data.closed_at : raw_data.updated_at
      end
    end
  end
end