mirror of
https://github.com/astuto/astuto.git
synced 2026-09-02 12:15:19 +02: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 |