Class: Gitlab::Diff::Formatters::FileFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/gitlab/diff/formatters/file_formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#base_sha, #head_sha, #ignore_whitespace_change, #new_path, #old_path, #start_sha

Instance Method Summary collapse

Methods inherited from BaseFormatter

#to_h

Constructor Details

#initialize(attrs) ⇒ FileFormatter

Returns a new instance of FileFormatter.



7
8
9
10
11
# File 'lib/gitlab/diff/formatters/file_formatter.rb', line 7

def initialize(attrs)
  @ignore_whitespace_change = false

  super(attrs)
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
28
29
# File 'lib/gitlab/diff/formatters/file_formatter.rb', line 25

def ==(other)
  other.is_a?(self.class) &&
    old_path == other.old_path &&
    new_path == other.new_path
end

#complete?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gitlab/diff/formatters/file_formatter.rb', line 21

def complete?
  [new_path, old_path].all?(&:present?)
end

#keyObject



13
14
15
# File 'lib/gitlab/diff/formatters/file_formatter.rb', line 13

def key
  @key ||= super.push(new_path, old_path)
end

#position_typeObject



17
18
19
# File 'lib/gitlab/diff/formatters/file_formatter.rb', line 17

def position_type
  "file"
end