summaryrefslogtreecommitdiff
path: root/lib/gitlab_access_status.rb
blob: 4b9d32a93cba1d6bd912c2fe153a493150da5b07 (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
require 'json'

class GitAccessStatus
  attr_reader :message, :repository_path, :memory_status, :memory_message

  def initialize(status, message, repository_path, memory = nil)
    @status = status
    @message = message
    @repository_path = repository_path

    if memory
      @memory_status = memory["status"]
      @memory_message = memory["message"]
    end
  end

  def self.create_from_json(json)
    values = JSON.parse(json)
    self.new(values["status"], values["message"],
             values["repository_path"], values["memory"])
  end

  def allowed?
    @status
  end

  def memory_limit?
    @memory_status
  end
end