Class: TenantKit::Configuration
- Inherits:
-
Object
- Object
- TenantKit::Configuration
- Defined in:
- lib/tenant_kit/configuration.rb
Overview
Instance Attribute Summary collapse
-
#propagate_to_jobs ⇒ Boolean
Carry the current tenant into ActiveJob background jobs.
-
#raise_on_missing_job_tenant ⇒ Boolean
Raise if a job is performed with no captured tenant (only consulted when #propagate_to_jobs is true).
-
#require_tenant ⇒ Boolean
Strict mode: raise NoTenantSet when a tenant-scoped query runs with no current tenant (and not inside
without_tenant). -
#tenant_class ⇒ String
Name of the model that represents a tenant (e.g. "Account").
-
#tenant_column ⇒ String
Foreign-key column on tenant-owned tables (e.g. "account_id").
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#tenant_model ⇒ Class
Resolves #tenant_class to the actual constant, lazily so it works with Rails autoloading / reloading.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
29 30 31 32 33 34 35 |
# File 'lib/tenant_kit/configuration.rb', line 29 def initialize @tenant_class = "Account" @tenant_column = "account_id" @require_tenant = true @propagate_to_jobs = true @raise_on_missing_job_tenant = false end |
Instance Attribute Details
#propagate_to_jobs ⇒ Boolean
Returns carry the current tenant into ActiveJob background jobs.
23 24 25 |
# File 'lib/tenant_kit/configuration.rb', line 23 def propagate_to_jobs @propagate_to_jobs end |
#raise_on_missing_job_tenant ⇒ Boolean
Returns raise if a job is performed with no captured tenant (only consulted when #propagate_to_jobs is true).
27 28 29 |
# File 'lib/tenant_kit/configuration.rb', line 27 def raise_on_missing_job_tenant @raise_on_missing_job_tenant end |
#require_tenant ⇒ Boolean
Returns strict mode: raise NoTenantSet when a tenant-scoped
query runs with no current tenant (and not inside without_tenant).
20 21 22 |
# File 'lib/tenant_kit/configuration.rb', line 20 def require_tenant @require_tenant end |
#tenant_class ⇒ String
Returns name of the model that represents a tenant (e.g. "Account").
13 14 15 |
# File 'lib/tenant_kit/configuration.rb', line 13 def tenant_class @tenant_class end |
#tenant_column ⇒ String
Returns foreign-key column on tenant-owned tables (e.g. "account_id").
16 17 18 |
# File 'lib/tenant_kit/configuration.rb', line 16 def tenant_column @tenant_column end |
Instance Method Details
#tenant_model ⇒ Class
Resolves #tenant_class to the actual constant, lazily so it works with Rails autoloading / reloading.
41 42 43 |
# File 'lib/tenant_kit/configuration.rb', line 41 def tenant_model tenant_class.to_s.constantize end |