summaryrefslogtreecommitdiff
path: root/lib/gitlab/import_export/after_export_strategy_builder.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-04-10 10:25:59 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-04-10 10:25:59 +0000
commit33a4439e8f079303fcf7c71267936e5c8f694958 (patch)
tree828c3c6dc55058e95927d36a3a03db9fd0263766 /lib/gitlab/import_export/after_export_strategy_builder.rb
parent2db218f8bf186c509c927ce3e9d0502fee4f8349 (diff)
parent174950b6562226beed7eef135a2450bfee60e21f (diff)
downloadgitlab-ce-33a4439e8f079303fcf7c71267936e5c8f694958.tar.gz
Merge branch 'master' into 'stuartnelson3/gitlab-ce-stn/issue-due-email'
# Conflicts: # db/schema.rb
Diffstat (limited to 'lib/gitlab/import_export/after_export_strategy_builder.rb')
-rw-r--r--lib/gitlab/import_export/after_export_strategy_builder.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/gitlab/import_export/after_export_strategy_builder.rb b/lib/gitlab/import_export/after_export_strategy_builder.rb
new file mode 100644
index 00000000000..7eabcae2380
--- /dev/null
+++ b/lib/gitlab/import_export/after_export_strategy_builder.rb
@@ -0,0 +1,24 @@
+module Gitlab
+ module ImportExport
+ class AfterExportStrategyBuilder
+ StrategyNotFoundError = Class.new(StandardError)
+
+ def self.build!(strategy_klass, attributes = {})
+ return default_strategy.new unless strategy_klass
+
+ attributes ||= {}
+ klass = strategy_klass.constantize rescue nil
+
+ unless klass && klass < AfterExportStrategies::BaseAfterExportStrategy
+ raise StrategyNotFoundError.new("Strategy #{strategy_klass} not found")
+ end
+
+ klass.new(**attributes.symbolize_keys)
+ end
+
+ def self.default_strategy
+ AfterExportStrategies::DownloadNotificationStrategy
+ end
+ end
+ end
+end