2020-05-22 05:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class SnippetInputActionCollection
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
|
|
|
attr_reader :actions
|
|
|
|
|
2020-05-26 14:08:20 -04:00
|
|
|
delegate :empty?, :any?, :[], to: :actions
|
2020-05-22 05:08:09 -04:00
|
|
|
|
2020-06-16 05:08:27 -04:00
|
|
|
def initialize(actions = [], allowed_actions: nil)
|
2020-09-28 08:10:02 -04:00
|
|
|
@actions = actions.map do |action|
|
|
|
|
params = action.merge(allowed_actions: allowed_actions)
|
|
|
|
|
|
|
|
SnippetInputAction.new(**params)
|
|
|
|
end
|
2020-05-22 05:08:09 -04:00
|
|
|
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
|