Class: PostgresMultitenant::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/postgres_multitenant/configuration.rb', line 21

def initialize
  @tenant_class_name = 'Organization'
  @tenant_finder = nil
  @tenant_scope_proc = nil
  @tenant_schema_name_proc = nil
  @tenant_foreign_key = 'organization_id'
  @tenant_table_resolver = nil
  @default_schema = 'public'
  @system_tables = %w[
    action_text_rich_texts
    active_storage_attachments
    active_storage_blobs
    active_storage_variant_records
  ]
  @excluded_subdomains = %w[www api admin mail ftp]
  @subdomain_extractor = nil
  @tenant_not_found_strategy = :raise
  @tenant_not_found_handler = nil
  @terminate_connections_on_drop = false
end

Instance Attribute Details

#default_schemaObject

Returns the value of attribute default_schema.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def default_schema
  @default_schema
end

#excluded_subdomainsObject

Returns the value of attribute excluded_subdomains.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def excluded_subdomains
  @excluded_subdomains
end

#subdomain_extractorObject

Returns the value of attribute subdomain_extractor.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def subdomain_extractor
  @subdomain_extractor
end

#system_tablesObject

Returns the value of attribute system_tables.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def system_tables
  @system_tables
end

#tenant_class_nameObject

Returns the value of attribute tenant_class_name.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_class_name
  @tenant_class_name
end

#tenant_finderObject

Returns the value of attribute tenant_finder.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_finder
  @tenant_finder
end

#tenant_foreign_keyObject

Returns the value of attribute tenant_foreign_key.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_foreign_key
  @tenant_foreign_key
end

#tenant_not_found_handlerObject

Returns the value of attribute tenant_not_found_handler.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_not_found_handler
  @tenant_not_found_handler
end

#tenant_not_found_strategyObject

Returns the value of attribute tenant_not_found_strategy.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_not_found_strategy
  @tenant_not_found_strategy
end

#tenant_schema_name_procObject

Returns the value of attribute tenant_schema_name_proc.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_schema_name_proc
  @tenant_schema_name_proc
end

#tenant_scope_procObject

Returns the value of attribute tenant_scope_proc.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_scope_proc
  @tenant_scope_proc
end

#tenant_table_resolverObject

Returns the value of attribute tenant_table_resolver.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def tenant_table_resolver
  @tenant_table_resolver
end

#terminate_connections_on_dropObject

Returns the value of attribute terminate_connections_on_drop.



7
8
9
# File 'lib/postgres_multitenant/configuration.rb', line 7

def terminate_connections_on_drop
  @terminate_connections_on_drop
end

Instance Method Details

#tenant_classObject



42
43
44
45
46
47
48
# File 'lib/postgres_multitenant/configuration.rb', line 42

def tenant_class
  return nil if tenant_class_name.to_s.empty?

  tenant_class_name.constantize
rescue NameError
  nil
end