Class: PgMultitenantSchemas::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_multitenant_schemas/configuration.rb

Overview

Configuration class for PgMultitenantSchemas gem settings. Manages tenant resolution, schema switching behavior, and Rails integration options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pg_multitenant_schemas/configuration.rb', line 12

def initialize
  @tenant_model_class = "Tenant"
  @default_schema = "public"
  # Enable development fallback with cookie support by default in development
  @development_fallback = false
  begin
    @development_fallback = ::Rails.env&.development? == true if defined?(::Rails)
  rescue StandardError
    # If Rails is not available, keep default
  end
  @excluded_subdomains = %w[www api admin mail ftp blog support help docs staging]
  @common_tlds = %w[com org net edu gov mil int co uk ca au de fr jp cn dev test]
  @auto_create_schemas = true
  @connection_class = "ApplicationRecord"
  @logger = defined?(::Rails) && ::Rails.respond_to?(:logger) ? ::Rails.logger : nil
end

Instance Attribute Details

#auto_create_schemasObject

Returns the value of attribute auto_create_schemas.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def auto_create_schemas
  @auto_create_schemas
end

#common_tldsObject

Returns the value of attribute common_tlds.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def common_tlds
  @common_tlds
end

#connection_classObject

Returns the value of attribute connection_class.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def connection_class
  @connection_class
end

#default_schemaObject

Returns the value of attribute default_schema.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def default_schema
  @default_schema
end

#development_fallbackObject

Returns the value of attribute development_fallback.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def development_fallback
  @development_fallback
end

#excluded_subdomainsObject

Returns the value of attribute excluded_subdomains.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def excluded_subdomains
  @excluded_subdomains
end

#loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def logger
  @logger
end

#tenant_model_classObject

Returns the value of attribute tenant_model_class.



8
9
10
# File 'lib/pg_multitenant_schemas/configuration.rb', line 8

def tenant_model_class
  @tenant_model_class
end

Instance Method Details

#tenant_modelObject



29
30
31
# File 'lib/pg_multitenant_schemas/configuration.rb', line 29

def tenant_model
  @tenant_model ||= tenant_model_class.constantize
end