Class: Railbow::MultiDb::Batch
- Inherits:
-
Object
- Object
- Railbow::MultiDb::Batch
- Defined in:
- lib/railbow/multi_db.rb
Instance Attribute Summary collapse
-
#git_cache ⇒ Object
readonly
Returns the value of attribute git_cache.
Instance Method Summary collapse
-
#add(section) ⇒ Object
Databases sharing a migrations path see the same files, so they merge into one section that carries a status per database.
- #claim_help ⇒ Object
- #empty? ⇒ Boolean
- #flush ⇒ Object
-
#initialize ⇒ Batch
constructor
A new instance of Batch.
-
#skip(name) ⇒ Object
A database excluded by RBW_DB.
Constructor Details
#initialize ⇒ Batch
Returns a new instance of Batch.
17 18 19 20 21 22 |
# File 'lib/railbow/multi_db.rb', line 17 def initialize @sections = [] @skipped = [] @git_cache = {} @help_shown = false end |
Instance Attribute Details
#git_cache ⇒ Object (readonly)
Returns the value of attribute git_cache.
15 16 17 |
# File 'lib/railbow/multi_db.rb', line 15 def git_cache @git_cache end |
Instance Method Details
#add(section) ⇒ Object
Databases sharing a migrations path see the same files, so they merge into one section that carries a status per database.
32 33 34 35 36 37 38 39 |
# File 'lib/railbow/multi_db.rb', line 32 def add(section) existing = @sections.find { |s| s.same_migrations?(section) } if existing existing.merge!(section) else @sections << section end end |
#claim_help ⇒ Object
41 42 43 44 45 |
# File 'lib/railbow/multi_db.rb', line 41 def claim_help return false if @help_shown @help_shown = true end |
#empty? ⇒ Boolean
47 48 49 |
# File 'lib/railbow/multi_db.rb', line 47 def empty? @sections.empty? && @skipped.empty? end |
#flush ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/railbow/multi_db.rb', line 51 def flush return if empty? Railbow::Status::Printer.new(@sections, skipped: @skipped).print @sections = [] @skipped = [] end |
#skip(name) ⇒ Object
A database excluded by RBW_DB. Recorded rather than dropped so the run can say what it left out.
26 27 28 |
# File 'lib/railbow/multi_db.rb', line 26 def skip(name) @skipped << name.to_s end |