Class: FuryDumper::Dumpers::ModelQueue
- Inherits:
-
Object
- Object
- FuryDumper::Dumpers::ModelQueue
- Defined in:
- lib/fury_dumper/dumpers/model_queue.rb
Instance Method Summary collapse
- #add_element(model:, dump_state:) ⇒ Object
- #count ⇒ Object
- #empty? ⇒ Boolean
- #fetch_element ⇒ Object
-
#initialize ⇒ ModelQueue
constructor
A new instance of ModelQueue.
Constructor Details
#initialize ⇒ ModelQueue
Returns a new instance of ModelQueue.
6 7 8 |
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 6 def initialize @queue = [] end |
Instance Method Details
#add_element(model:, dump_state:) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 10 def add_element(model:, dump_state:) raise ArgumentError, "Expected model as Dumpers::Model, got: #{model.class}" unless model.is_a?(Model) unless dump_state.is_a?(DumpState) raise ArgumentError, "Expected dump_state as Dumpers::DumpState, got: #{dump_state.class}" end @queue << [model, dump_state] end |
#count ⇒ Object
29 30 31 |
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 29 def count @queue.count end |
#empty? ⇒ Boolean
21 22 23 |
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 21 def empty? @queue.empty? end |
#fetch_element ⇒ Object
25 26 27 |
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 25 def fetch_element @queue.delete_at(0) end |