debian-mirror-gitlab/app/models/snippet_input_action_collection.rb
2020-06-23 00:09:42 +05:30

25 lines
570 B
Ruby

# 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