Exception: MultiTenant::TenantsNotFound

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/acts_as_multi_tenant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenant_class, identifiers, found_records) ⇒ TenantsNotFound

Returns a new instance of TenantsNotFound.



15
16
17
18
19
# File 'lib/acts_as_multi_tenant.rb', line 15

def initialize(tenant_class, identifiers, found_records)
  @tenant_class = tenant_class
  @identifiers = identifiers
  @found_records = found_records
end

Instance Attribute Details

#tenant_classObject (readonly)

Returns the value of attribute tenant_class.



13
14
15
# File 'lib/acts_as_multi_tenant.rb', line 13

def tenant_class
  @tenant_class
end

Instance Method Details

#messageObject



32
33
34
# File 'lib/acts_as_multi_tenant.rb', line 32

def message
  "The following #{@tenant_class.name} tenants could not be found: #{not_found.join ", "}"
end

#not_foundObject

Returns an array of the tenant identifiers that could not be found



22
23
24
25
26
# File 'lib/acts_as_multi_tenant.rb', line 22

def not_found
  @not_found ||= @identifiers.map(&:to_s) - @found_records.map { |tenant|
    tenant.send(@tenant_class.tenant_identifier).to_s
  }
end

#to_sObject



28
29
30
# File 'lib/acts_as_multi_tenant.rb', line 28

def to_s
  message
end