Merge pull request #42 from yzzy/zeitwerk

Plugin autoloading with Zeitwerk
This commit is contained in:
Ryo SUETSUGU
2022-04-16 16:12:20 +09:00
committed by GitHub
4 changed files with 15 additions and 5 deletions

View File

@@ -1 +1,3 @@
source 'https://rubygems.org'
gem 'faraday'

View File

@@ -1,4 +1,10 @@
require 'redmine_webhook'
if Rails.try(:autoloaders).try(:zeitwerk_enabled?)
Rails.autoloaders.main.push_dir File.dirname(__FILE__) + '/lib/redmine_webhook'
RedmineWebhook::ProjectsHelperPatch
RedmineWebhook::WebhookListener
else
require "redmine_webhook"
end
Redmine::Plugin.register :redmine_webhook do
name 'Redmine Webhook plugin'

View File

@@ -1,6 +1,8 @@
require 'redmine_webhook/projects_helper_patch'
require 'redmine_webhook/issue_wrapper'
require 'redmine_webhook/webhook_listener'
unless Rails.try(:autoloaders).try(:zeitwerk_enabled?)
require 'redmine_webhook/projects_helper_patch'
require 'redmine_webhook/issue_wrapper'
require 'redmine_webhook/webhook_listener'
end
module RedmineWebhook
end

View File

@@ -15,7 +15,7 @@ module RedmineWebhook
:mail => @author.mail,
:firstname => @author.firstname,
:lastname => @author.lastname,
:identity_url => @author.identity_url,
:identity_url => @author.try(:identity_url),
:icon_url => icon_url
}
end