Class: Seedy::AbstractBuffer
- Inherits:
-
Object
- Object
- Seedy::AbstractBuffer
- Defined in:
- lib/seedy/buffer/abstract_buffer.rb
Direct Known Subclasses
Constant Summary collapse
- @@buffer =
[]
- @@limit =
5
Class Method Summary collapse
Class Method Details
.<<(record) ⇒ Object
8 9 10 11 12 |
# File 'lib/seedy/buffer/abstract_buffer.rb', line 8 def <<(record) raise InvalidRecord, record.table_name + ": " + record.errors.to_a.join(", ") unless record.valid? @@buffer << record flush if @@buffer.length >= @@limit end |
.flush ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/seedy/buffer/abstract_buffer.rb', line 13 def flush puts "Flushing!" @@buffer.length.times { record = @@buffer.shift if record.valid? puts record.to_sql else puts record.errors end } end |