summaryrefslogtreecommitdiff
path: root/app/models/snippet_input_action_collection.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/models/snippet_input_action_collection.rb
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/models/snippet_input_action_collection.rb')
-rw-r--r--app/models/snippet_input_action_collection.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/snippet_input_action_collection.rb b/app/models/snippet_input_action_collection.rb
new file mode 100644
index 00000000000..38313e3a980
--- /dev/null
+++ b/app/models/snippet_input_action_collection.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class SnippetInputActionCollection
+ include Gitlab::Utils::StrongMemoize
+
+ attr_reader :actions
+
+ delegate :empty?, :any?, :[], to: :actions
+
+ def initialize(actions = [], allowed_actions: nil)
+ @actions = actions.map { |action| SnippetInputAction.new(action.merge(allowed_actions: allowed_actions)) }
+ end
+
+ def to_commit_actions
+ strong_memoize(:commit_actions) do
+ actions.map { |action| action.to_commit_action }
+ end
+ end
+
+ def valid?
+ strong_memoize(:valid) do
+ actions.all?(&:valid?)
+ end
+ end
+end