Class: FuryDumper::Dumpers::ModelQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/fury_dumper/dumpers/model_queue.rb

Instance Method Summary collapse

Constructor Details

#initializeModelQueue

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

Raises:

  • (ArgumentError)


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

#countObject



29
30
31
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 29

def count
  @queue.count
end

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 21

def empty?
  @queue.empty?
end

#fetch_elementObject



25
26
27
# File 'lib/fury_dumper/dumpers/model_queue.rb', line 25

def fetch_element
  @queue.delete_at(0)
end