Sha256: 020ca4bc8823224184936de2149c29e54ca7c7bd034fe27691f97800707ba801
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require 'active_support/inflector/methods' module AppMap # Specific hook handler classes and general related utilities. module Handler # Try to find handler module with a given name. # # If the module is not loaded, tries to require the appropriate file # using the usual conventions, eg. `Acme::Handler::AppMap` will try # to require `acme/handler/app_map`, then `acme/handler` and # finally `acme`. Raises NameError if the module could not be loaded # this way. def self.find(name) begin return Object.const_get name rescue NameError try_load ActiveSupport::Inflector.underscore name end Object.const_get name end def self.try_load(fname) fname = fname.sub %r{^app_map/}, 'appmap/' fname = fname.split '/' until fname.empty? begin require fname.join '/' return rescue LoadError # pass end fname.pop end end end end
Version data entries
8 entries across 8 versions & 1 rubygems