Module: Postbox::Stack

Extended by:
Enumerable, Stack
Included in:
Stack
Defined in:
lib/postbox/stack.rb

Instance Method Summary collapse

Instance Method Details

#<<(item) ⇒ Object



8
9
10
# File 'lib/postbox/stack.rb', line 8

def << (item)
  stack << item
end

#eachObject



16
17
18
# File 'lib/postbox/stack.rb', line 16

def each
  stack.each { |e| yield(e) }
end

#empty?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/postbox/stack.rb', line 20

def empty?
  stack.empty?
end

#push(url, params = {}, &callback) ⇒ Object



32
33
34
35
36
# File 'lib/postbox/stack.rb', line 32

def push(url, params = {}, &callback)
  stack << item = OpenStruct.new(:url => url, :params => params, :callback => callback, :post_attempts => 0)
  Postbox::Worker.wakeup
  return item
end

#shiftObject



24
25
26
# File 'lib/postbox/stack.rb', line 24

def shift
  stack.shift
end

#sizeObject



28
29
30
# File 'lib/postbox/stack.rb', line 28

def size
  stack.size
end

#stackObject



12
13
14
# File 'lib/postbox/stack.rb', line 12

def stack
  @stack ||= []
end