Class: SnippetInputAction

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/snippet_input_action.rb

Constant Summary collapse

ACTIONS =
%i[create update delete move].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action: nil, previous_path: nil, file_path: nil, content: nil, allowed_actions: nil) ⇒ SnippetInputAction

Returns a new instance of SnippetInputAction.



24
25
26
27
28
29
30
# File 'app/models/snippet_input_action.rb', line 24

def initialize(action: nil, previous_path: nil, file_path: nil, content: nil, allowed_actions: nil)
  @action = action&.to_sym
  @previous_path = previous_path
  @file_path = file_path
  @content = content
  @allowed_actions = Array(allowed_actions).map(&:to_sym)
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



14
15
16
# File 'app/models/snippet_input_action.rb', line 14

def action
  @action
end

#contentObject (readonly)

Returns the value of attribute content.



14
15
16
# File 'app/models/snippet_input_action.rb', line 14

def content
  @content
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



14
15
16
# File 'app/models/snippet_input_action.rb', line 14

def file_path
  @file_path
end

#previous_pathObject (readonly)

Returns the value of attribute previous_path.



14
15
16
# File 'app/models/snippet_input_action.rb', line 14

def previous_path
  @previous_path
end

Instance Method Details

#to_commit_actionObject



32
33
34
35
36
37
38
39
# File 'app/models/snippet_input_action.rb', line 32

def to_commit_action
  {
    action: action,
    previous_path: build_previous_path,
    file_path: file_path,
    content: content
  }
end