debian-mirror-gitlab/lib/api/helpers/version.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
526 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module API
module Helpers
class Version
include Helpers::RelatedResourcesHelpers
def initialize(version)
@version = version.to_s
unless API.versions.include?(version)
raise ArgumentError, 'Unknown API version!'
end
end
def root_path
File.join('/', API.prefix.to_s, @version)
end
def root_url
@root_url ||= expose_url(root_path)
end
def to_s
@version
end
end
end
end