summaryrefslogtreecommitdiff
path: root/lib/atlassian/jira_connect/serializers/base_entity.rb
blob: 640337c0399401273a03b9d7e039c8dfd467be0f (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
# frozen_string_literal: true

module Atlassian
  module JiraConnect
    module Serializers
      class BaseEntity < Grape::Entity
        include Gitlab::Routing
        include GitlabRoutingHelper

        format_with(:string) { |value| value.to_s }

        expose :update_sequence_id, as: :updateSequenceId

        def eql(other)
          other.is_a?(self.class) && to_json == other.to_json
        end

        alias_method :==, :eql

        private

        def update_sequence_id
          options[:update_sequence_id] || Client.generate_update_sequence_id
        end
      end
    end
  end
end