Class: MetaCommit::Models::Changes::Commit
- Inherits:
-
Object
- Object
- MetaCommit::Models::Changes::Commit
- Defined in:
- lib/meta_commit/models/changes/commit.rb
Overview
Collection of file changes
Instance Attribute Summary collapse
-
#file_changes ⇒ Array<MetaCommit::Contracts::Diff>
The current value of file_changes.
-
#new_commit_id ⇒ Symbol
The current value of new_commit_id.
-
#old_commit_id ⇒ Symbol
The current value of old_commit_id.
Instance Method Summary collapse
- #commit_id ⇒ String
- #each { ... } ⇒ Object
- #empty? ⇒ Boolean
- #include?(change) ⇒ Boolean
-
#initialize(old_commit_id, new_commit_id) ⇒ Commit
constructor
A new instance of Commit.
- #push(file_change) ⇒ Object
- #push_changes(file_changes) ⇒ Object
Constructor Details
#initialize(old_commit_id, new_commit_id) ⇒ Commit
Returns a new instance of Commit.
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_changes ⇒ Array<MetaCommit::Contracts::Diff>
Returns 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_id ⇒ Symbol
Returns 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_id ⇒ Symbol
Returns 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_id ⇒ 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
37 38 39 |
# File 'lib/meta_commit/models/changes/commit.rb', line 37 def each(&block) @file_changes.each(&block) end |
#empty? ⇒ Boolean
42 43 44 |
# File 'lib/meta_commit/models/changes/commit.rb', line 42 def empty? @file_changes.empty? end |
#include?(change) ⇒ 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
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
23 24 25 |
# File 'lib/meta_commit/models/changes/commit.rb', line 23 def push_changes(file_changes) @file_changes+=file_changes end |