-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5284 from samvera/analytics-parser-fallback
provide a NullAnalyticsParser if no analytics provider is given
- Loading branch information
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
# frozen_string_literal: true | ||
module Hyrax | ||
module Analytics | ||
## | ||
# a completely empty module to include if no parser is configured | ||
module NullAnalyticsParser; end | ||
|
||
def self.provider_parser | ||
"Hyrax::Analytics::#{Hyrax.config.analytics_provider.to_s.capitalize}" | ||
"Hyrax::Analytics::#{Hyrax.config.analytics_provider.to_s.capitalize}".constantize | ||
rescue NameError => err | ||
Hyrax.logger.warn("Couldn't find an Analtics provider matching "\ | ||
" #{Hyrax.config.analytics_provider}. Loading " \ | ||
" NullAnalyticsProvider.\n#{err.message}") | ||
NullAnalyticsParser | ||
end | ||
include provider_parser.constantize | ||
|
||
include provider_parser | ||
end | ||
end |