Exception: Apartment::DefaultTenantRequired

Inherits:
ApartmentError
  • Object
show all
Defined in:
lib/apartment/errors.rb

Overview

Raised by Apartment::Tenant.require_default_tenant! when the effective tenant is a real (non-default) tenant — pinned/global work must run in the default.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current = nil, default = nil) ⇒ DefaultTenantRequired

Returns a new instance of DefaultTenantRequired.



104
105
106
107
108
109
110
111
112
# File 'lib/apartment/errors.rb', line 104

def initialize(current = nil, default = nil)
  @current = current
  @default = default
  super(
    "Expected the default tenant #{default.inspect}, but the effective " \
    "tenant is #{current.inspect}. Wrap pinned/global work in " \
    'Apartment::Tenant.with_default_tenant { ... }.'
  )
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



102
103
104
# File 'lib/apartment/errors.rb', line 102

def current
  @current
end

#defaultObject (readonly)

Returns the value of attribute default.



102
103
104
# File 'lib/apartment/errors.rb', line 102

def default
  @default
end