Class: SnippetInputActionCollection

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/models/snippet_input_action_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(actions = [], allowed_actions: nil) ⇒ SnippetInputActionCollection

Returns a new instance of SnippetInputActionCollection.


10
11
12
# File 'app/models/snippet_input_action_collection.rb', line 10

def initialize(actions = [], allowed_actions: nil)
  @actions = actions.map { |action| SnippetInputAction.new(action.merge(allowed_actions: allowed_actions)) }
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions


6
7
8
# File 'app/models/snippet_input_action_collection.rb', line 6

def actions
  @actions
end

Instance Method Details

#to_commit_actionsObject


14
15
16
17
18
# File 'app/models/snippet_input_action_collection.rb', line 14

def to_commit_actions
  strong_memoize(:commit_actions) do
    actions.map { |action| action.to_commit_action }
  end
end

#valid?Boolean

Returns:

  • (Boolean)

20
21
22
23
24
# File 'app/models/snippet_input_action_collection.rb', line 20

def valid?
  strong_memoize(:valid) do
    actions.all?(&:valid?)
  end
end