Class: FlexMock::PartialMockProxy::ProxyBox

Inherits:
Object
  • Object
show all
Defined in:
lib/flexmock/partial_mock.rb

Overview

Boxing of the flexmock proxy

It is managed as a stack in order to allow to setup containers recursively (as e.g. FlexMock.use( … ) checks)

Defined Under Namespace

Classes: Element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxyBox

Returns a new instance of ProxyBox.



40
41
42
# File 'lib/flexmock/partial_mock.rb', line 40

def initialize
  @stack = [Element.new]
end

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



36
37
38
# File 'lib/flexmock/partial_mock.rb', line 36

def stack
  @stack
end

Instance Method Details

#containerObject

Tests whether the given container is the one on which the current proxy acts



46
47
48
# File 'lib/flexmock/partial_mock.rb', line 46

def container
  stack.last.container
end

#empty?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/flexmock/partial_mock.rb', line 64

def empty?
  stack.size == 1
end

#popObject



58
59
60
61
62
# File 'lib/flexmock/partial_mock.rb', line 58

def pop
  if !stack.empty?
    stack.pop
  end
end

#proxyObject



50
51
52
# File 'lib/flexmock/partial_mock.rb', line 50

def proxy
  stack.last.proxy
end

#push(proxy, container) ⇒ Object



54
55
56
# File 'lib/flexmock/partial_mock.rb', line 54

def push(proxy, container)
  stack.push(Element.new(proxy, container))
end