summaryrefslogtreecommitdiff
path: root/lib/banzai/reference_parser.rb
blob: 8b5d689a984143e9ae1e4fc2ba52f90a14ae0afc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Banzai
  module ReferenceParser
    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)
      const_get("#{name.to_s.camelize}Parser", false)
    rescue NameError
      raise InvalidReferenceType
    end
  end
end