Files
astuto/app/models/current.rb
2022-07-18 10:47:54 +02:00

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