Class: MetaCommit::Models::Changes::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_commit/models/changes/commit.rb

Overview

Collection of file changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(old_commit_id, new_commit_id) ⇒ Commit

Returns a new instance of Commit.

Parameters:

  • old_commit_id (Symbol)
  • new_commit_id (Symbol)


11
12
13
14
15
# File 'lib/meta_commit/models/changes/commit.rb', line 11

def initialize(old_commit_id, new_commit_id)
  @old_commit_id = old_commit_id
  @new_commit_id = new_commit_id
  @file_changes = []
end

Instance Attribute Details

#file_changesArray<MetaCommit::Contracts::Diff>

Returns the current value of file_changes.

Returns:

  • (Array<MetaCommit::Contracts::Diff>)

    the current value of file_changes



6
7
8
# File 'lib/meta_commit/models/changes/commit.rb', line 6

def file_changes
  @file_changes
end

#new_commit_idSymbol

Returns the current value of new_commit_id.

Returns:

  • (Symbol)

    the current value of new_commit_id



6
7
8
# File 'lib/meta_commit/models/changes/commit.rb', line 6

def new_commit_id
  @new_commit_id
end

#old_commit_idSymbol

Returns the current value of old_commit_id.

Returns:

  • (Symbol)

    the current value of old_commit_id



6
7
8
# File 'lib/meta_commit/models/changes/commit.rb', line 6

def old_commit_id
  @old_commit_id
end

Instance Method Details

#commit_idString

Returns:

  • (String)


28
29
30
31
32
33
34
# File 'lib/meta_commit/models/changes/commit.rb', line 28

def commit_id
  if @old_commit_id == @new_commit_id
    @new_commit_id
  else
    "#{@old_commit_id} -> #{@new_commit_id}"
  end
end

#each { ... } ⇒ Object

Yields:

  • file changes



37
38
39
# File 'lib/meta_commit/models/changes/commit.rb', line 37

def each(&block)
  @file_changes.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/meta_commit/models/changes/commit.rb', line 42

def empty?
  @file_changes.empty?
end

#include?(change) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/meta_commit/models/changes/commit.rb', line 47

def include?(change)
  @file_changes.include?(change)
end

#push(file_change) ⇒ Object

Parameters:

  • file_change (MetaCommit::Contracts::Diff)


18
19
20
# File 'lib/meta_commit/models/changes/commit.rb', line 18

def push(file_change)
  @file_changes.push(file_change)
end

#push_changes(file_changes) ⇒ Object

Parameters:

  • file_changes (Array<MetaCommit::Contracts::Diff>)


23
24
25
# File 'lib/meta_commit/models/changes/commit.rb', line 23

def push_changes(file_changes)
  @file_changes+=file_changes
end