summaryrefslogtreecommitdiff
path: root/lib/gitlab/gitaly_client/wiki_page.rb
blob: 757a429fb8a74e9d9c8f11ce1714251c5be30efa (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
# frozen_string_literal: true

module Gitlab
  module GitalyClient
    class WikiPage
      ATTRS = %i(title format url_path path name historical raw_data).freeze

      include AttributesBag
      include Gitlab::EncodingHelper

      def initialize(params)
        super

        # All gRPC strings in a response are frozen, so we get an unfrozen
        # version here so appending to `raw_data` doesn't blow up.
        @raw_data = @raw_data.dup

        @title = encode_utf8(@title)
        @path = encode_utf8(@path)
        @name = encode_utf8(@name)
      end

      def historical?
        @historical
      end

      def format
        @format.to_sym
      end
    end
  end
end