2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2014-05-03 12:34:36 +00:00
|
|
|
module ApplicationLib
|
|
|
|
def self.included(base)
|
|
|
|
base.extend(ClassMethods)
|
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
2013-08-15 21:15:05 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
load adapter based on setting option
|
|
|
|
|
2015-12-16 21:47:10 +00:00
|
|
|
result = self.load_adapter_by_setting('some_setting_with_class_name')
|
2013-08-15 21:15:05 +00:00
|
|
|
|
|
|
|
returns
|
|
|
|
|
2013-08-17 16:09:06 +00:00
|
|
|
result = Some::Classname
|
2013-08-15 21:15:05 +00:00
|
|
|
|
|
|
|
=end
|
|
|
|
|
2014-05-03 12:34:36 +00:00
|
|
|
def load_adapter_by_setting(setting)
|
2015-12-16 21:47:10 +00:00
|
|
|
adapter = Setting.get(setting)
|
2017-11-23 08:09:44 +00:00
|
|
|
return if adapter.blank?
|
2013-08-15 20:40:22 +00:00
|
|
|
|
2019-01-06 18:41:29 +00:00
|
|
|
adapter.constantize
|
2014-05-03 12:34:36 +00:00
|
|
|
end
|
2013-08-15 20:40:22 +00:00
|
|
|
end
|
|
|
|
end
|