Class: Stagehand::Staging::Commit
- Inherits:
-
Object
- Object
- Stagehand::Staging::Commit
- Defined in:
- lib/stagehand/staging/commit.rb
Class Method Summary collapse
- .all ⇒ Object
- .capture(subject_record = nil, &block) ⇒ Object
- .containing(record) ⇒ Object
- .find(start_ids) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #entries ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #id ⇒ Object
- #include?(record) ⇒ Boolean
-
#initialize(start_id) ⇒ Commit
constructor
A new instance of Commit.
Constructor Details
#initialize(start_id) ⇒ Commit
Returns a new instance of Commit.
60 61 62 63 64 65 66 |
# File 'lib/stagehand/staging/commit.rb', line 60 def initialize(start_id) @start_id, @end_id = CommitEntry.control_operations .where(:commit_id => start_id) .where('id >= ?', start_id).limit(2).pluck(:id) raise CommitNotFound unless @start_id && @end_id end |
Class Method Details
.all ⇒ Object
4 5 6 |
# File 'lib/stagehand/staging/commit.rb', line 4 def self.all CommitEntry.start_operations.pluck(:id).collect {|id| find(id) } end |
.capture(subject_record = nil, &block) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/stagehand/staging/commit.rb', line 8 def self.capture(subject_record = nil, &block) start_operation = start_commit(subject_record) block.call return end_commit(start_operation) rescue => e end_commit(start_operation) raise(e) end |
.containing(record) ⇒ Object
17 18 19 |
# File 'lib/stagehand/staging/commit.rb', line 17 def self.containing(record) find(CommitEntry.contained.matching(record).pluck(:commit_id)) end |
.find(start_ids) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/stagehand/staging/commit.rb', line 21 def self.find(start_ids) if start_ids.respond_to?(:each) start_ids.to_a.uniq.collect {|id| find(id) }.compact else new(start_ids) end rescue CommitNotFound end |
Instance Method Details
#==(other) ⇒ Object
84 85 86 |
# File 'lib/stagehand/staging/commit.rb', line 84 def ==(other) id == other.id end |
#entries ⇒ Object
88 89 90 |
# File 'lib/stagehand/staging/commit.rb', line 88 def entries CommitEntry.where(:id => @start_id..@end_id).where(:commit_id => id) end |
#eql?(other) ⇒ Boolean
80 81 82 |
# File 'lib/stagehand/staging/commit.rb', line 80 def eql?(other) self == other end |
#hash ⇒ Object
76 77 78 |
# File 'lib/stagehand/staging/commit.rb', line 76 def hash id end |
#id ⇒ Object
68 69 70 |
# File 'lib/stagehand/staging/commit.rb', line 68 def id @start_id end |
#include?(record) ⇒ Boolean
72 73 74 |
# File 'lib/stagehand/staging/commit.rb', line 72 def include?(record) entries.where(:record_id => record.id, :table_name => record.class.table_name).exists? end |