Class: Gitlab::ChangesList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gitlab/changes_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changes) ⇒ ChangesList

Returns a new instance of ChangesList.


9
10
11
# File 'lib/gitlab/changes_list.rb', line 9

def initialize(changes)
  @raw_changes = changes.is_a?(String) ? changes.lines : changes
end

Instance Attribute Details

#raw_changesObject (readonly)

Returns the value of attribute raw_changes


7
8
9
# File 'lib/gitlab/changes_list.rb', line 7

def raw_changes
  @raw_changes
end

Instance Method Details

#changesObject


17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/changes_list.rb', line 17

def changes
  @changes ||= begin
    @raw_changes.map do |change|
      next if change.blank?

      oldrev, newrev, ref = change.strip.split(' ')
      { oldrev: oldrev, newrev: newrev, ref: ref }
    end.compact
  end
end

#each(&block) ⇒ Object


13
14
15
# File 'lib/gitlab/changes_list.rb', line 13

def each(&block)
  changes.each(&block)
end