diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/current_settings.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/current_settings.rb b/lib/current_settings.rb new file mode 100644 index 0000000..59dedfd --- /dev/null +++ b/lib/current_settings.rb @@ -0,0 +1,20 @@ +module CurrentSettings + def current_application_settings + key = :current_application_settings + + RequestStore.store[key] ||= begin + if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?('application_settings') + ApplicationSetting.current || ApplicationSetting.create_from_defaults + else + fake_application_settings + end + end + end + + def fake_application_settings + OpenStruct.new( + all_broken_builds: Settings.gitlab_ci['all_broken_builds'], + add_pusher: Settings.gitlab_ci['add_pusher'], + ) + end +end |