Class: Ekylibre::MultiTenancy::TenantStack
- Inherits:
-
Object
- Object
- Ekylibre::MultiTenancy::TenantStack
- 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
- #current ⇒ Tenant?
-
#initialize ⇒ TenantStack
constructor
A new instance of TenantStack.
- #pop ⇒ Object
- #push(tenant) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ TenantStack
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
#current ⇒ Tenant?
12 13 14 |
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 12 def current @stack.last end |
#pop ⇒ Object
16 17 18 19 20 |
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 16 def pop @stack.pop nil end |
#push(tenant) ⇒ Object
23 24 25 |
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 23 def push(tenant) @stack << tenant end |
#size ⇒ Object
27 28 29 |
# File 'lib/ekylibre/multi_tenancy/tenant_stack.rb', line 27 def size @stack.size end |