2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-26 07:16:43 -04:00
|
|
|
module Banzai
|
|
|
|
module ReferenceParser
|
2020-10-16 14:09:04 -04:00
|
|
|
InvalidReferenceType = Class.new(StandardError)
|
|
|
|
|
2016-05-26 07:16:43 -04:00
|
|
|
# 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-10-15 23:06:12 -04:00
|
|
|
const_get("#{name.to_s.camelize}Parser", false)
|
2020-10-16 14:09:04 -04:00
|
|
|
rescue NameError
|
|
|
|
raise InvalidReferenceType
|
2016-05-26 07:16:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|