debian-mirror-gitlab/lib/banzai/reference_parser.rb

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

21 lines
481 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
module Banzai
module ReferenceParser
2021-01-03 14:25:43 +05:30
InvalidReferenceType = Class.new(StandardError)
# Returns the reference parser class for the given type
#
# Example:
#
# Banzai::ReferenceParser['issue']
#
# This would return the `Banzai::ReferenceParser::IssueParser` class.
def self.[](name)
2019-12-21 20:55:43 +05:30
const_get("#{name.to_s.camelize}Parser", false)
2021-01-03 14:25:43 +05:30
rescue NameError
raise InvalidReferenceType
end
end
end