Class: Hamster::MutableStack

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ReadCopyUpdate
Defined in:
lib/hamster/experimental/mutable_stack.rb

Instance Method Summary collapse

Methods included from ReadCopyUpdate

#eql?, #initialize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hamster::ReadCopyUpdate

Instance Method Details

#popObject



23
24
25
26
27
28
29
30
# File 'lib/hamster/experimental/mutable_stack.rb', line 23

def pop
  top = nil
  transform { |stack|
    top = stack.peek
    stack.pop
  }
  top
end

#push(item) ⇒ Object



17
18
19
# File 'lib/hamster/experimental/mutable_stack.rb', line 17

def push(item)
  transform { |stack| stack.push(item) }
end