Class: Ekylibre::MultiTenancy::TenantStack

Inherits:
Object
  • Object
show all
Defined in:
lib/ekylibre/multi_tenancy/tenant_stack.rb

Overview

Stack allowing to track which is the current tenant across multiple nested contexts

Instance Method Summary collapse

Constructor Details

#initializeTenantStack

Returns a new instance of TenantStack.



7
8
9
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 7

def initialize
  @stack = []
end

Instance Method Details

#currentTenant?

Returns:



12
13
14
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 12

def current
  @stack.last
end

#popObject



16
17
18
19
20
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 16

def pop
  @stack.pop

  nil
end

#push(tenant) ⇒ Object

Parameters:



23
24
25
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 23

def push(tenant)
  @stack << tenant
end

#sizeObject



27
28
29
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 27

def size
  @stack.size
end