mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
13 lines
385 B
Ruby
13 lines
385 B
Ruby
|
|
class Current < ActiveSupport::CurrentAttributes
|
||
|
|
attribute :tenant
|
||
|
|
|
||
|
|
class MissingCurrentTenant < StandardError; end
|
||
|
|
class CurrentTenantNotActive < StandardError; end
|
||
|
|
|
||
|
|
def tenant_or_raise!
|
||
|
|
raise MissingCurrentTenant, "Current tenant is not set" unless tenant
|
||
|
|
raise CurrentTenantBlocked, "Current tenant is blocked" unless tenant.status != "blocked"
|
||
|
|
|
||
|
|
tenant
|
||
|
|
end
|
||
|
|
end
|