Module: Apartment
- Extended by:
- Forwardable
- Defined in:
- lib/apartment.rb,
lib/apartment/railtie.rb,
lib/apartment/version.rb,
lib/apartment/database.rb,
lib/apartment/migrator.rb,
lib/apartment/reloader.rb,
lib/apartment/elevators/domain.rb,
lib/apartment/elevators/generic.rb,
lib/apartment/elevators/host_hash.rb,
lib/apartment/elevators/subdomain.rb,
lib/apartment/adapters/mysql2_adapter.rb,
lib/apartment/adapters/postgis_adapter.rb,
lib/apartment/adapters/sqlite3_adapter.rb,
lib/apartment/adapters/abstract_adapter.rb,
lib/apartment/elevators/first_subdomain.rb,
lib/apartment/adapters/jdbc_mysql_adapter.rb,
lib/apartment/adapters/postgresql_adapter.rb,
lib/apartment/adapters/abstract_jdbc_adapter.rb,
lib/apartment/adapters/jdbc_postgresql_adapter.rb,
lib/generators/apartment/install/install_generator.rb
Defined Under Namespace
Modules: Adapters, Database, Elevators, Migrator Classes: InstallGenerator, Railtie, Reloader
Constant Summary collapse
- ACCESSOR_METHODS =
[:use_schemas, :seed_after_create, :prepend_environment, :append_environment]
- WRITER_METHODS =
[:tenant_names, :database_schema_file, :excluded_models, :default_schema, :persistent_schemas, :connection_class, :tld_length]
- ApartmentError =
Exceptions
Class.new(StandardError)
- AdapterNotFound =
Raised when apartment cannot find the adapter specified in
config/database.yml
Class.new(ApartmentError)
- TenantNotFound =
Tenant specified is unknown
Class.new(ApartmentError)
- DatabaseNotFound =
Raised when database cannot find the specified database
Class.new(TenantNotFound)
- SchemaNotFound =
Raised when database cannot find the specified schema
Class.new(TenantNotFound)
- TenantExists =
The Tenant attempting to be created already exists
Class.new(ApartmentError)
- DatabaseExists =
Raised when trying to create a database that already exists
Class.new(TenantExists)
- SchemaExists =
Raised when trying to create a schema that already exists
Class.new(TenantExists)
- VERSION =
"0.24.0"
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
configure apartment with available options.
- .connection_class ⇒ Object
- .database_names ⇒ Object
- .database_names=(names) ⇒ Object
- .database_schema_file ⇒ Object
- .default_schema ⇒ Object
-
.excluded_models ⇒ Object
Default to empty array.
- .persistent_schemas ⇒ Object
-
.reset ⇒ Object
Reset all the config for Apartment.
-
.tenant_names ⇒ Object
Be careful not to use ‘return` here so both Proc and lambda can be used without breaking.
- .tld_length ⇒ Object
- .use_postgres_schemas ⇒ Object
- .use_postgres_schemas=(to_use_or_not_to_use) ⇒ Object
Class Method Details
.configure {|_self| ... } ⇒ Object
configure apartment with available options
22 23 24 |
# File 'lib/apartment.rb', line 22 def configure yield self if block_given? end |
.connection_class ⇒ Object
44 45 46 |
# File 'lib/apartment.rb', line 44 def connection_class @connection_class || ActiveRecord::Base end |
.database_names ⇒ Object
63 64 65 66 |
# File 'lib/apartment.rb', line 63 def database_names warn "[Deprecation Warning] `database_names` is now deprecated, please use `tenant_names`" tenant_names end |
.database_names=(names) ⇒ Object
68 69 70 71 |
# File 'lib/apartment.rb', line 68 def database_names=(names) warn "[Deprecation Warning] `database_names=` is now deprecated, please use `tenant_names=`" self.tenant_names=(names) end |
.database_schema_file ⇒ Object
48 49 50 51 52 |
# File 'lib/apartment.rb', line 48 def database_schema_file return @database_schema_file if defined?(@database_schema_file) @database_schema_file = Rails.root.join('db', 'schema.rb') end |
.default_schema ⇒ Object
36 37 38 |
# File 'lib/apartment.rb', line 36 def default_schema @default_schema || "public" end |
.excluded_models ⇒ Object
Default to empty array
32 33 34 |
# File 'lib/apartment.rb', line 32 def excluded_models @excluded_models || [] end |
.persistent_schemas ⇒ Object
40 41 42 |
# File 'lib/apartment.rb', line 40 def persistent_schemas @persistent_schemas || [] end |
.reset ⇒ Object
Reset all the config for Apartment
59 60 61 |
# File 'lib/apartment.rb', line 59 def reset (ACCESSOR_METHODS + WRITER_METHODS).each{|method| remove_instance_variable(:"@#{method}") if instance_variable_defined?(:"@#{method}") } end |
.tenant_names ⇒ Object
Be careful not to use ‘return` here so both Proc and lambda can be used without breaking
27 28 29 |
# File 'lib/apartment.rb', line 27 def tenant_names @tenant_names.respond_to?(:call) ? @tenant_names.call : @tenant_names end |
.tld_length ⇒ Object
54 55 56 |
# File 'lib/apartment.rb', line 54 def tld_length @tld_length || 1 end |
.use_postgres_schemas ⇒ Object
73 74 75 76 |
# File 'lib/apartment.rb', line 73 def use_postgres_schemas warn "[Deprecation Warning] `use_postgresql_schemas` is now deprecated, please use `use_schemas`" use_schemas end |
.use_postgres_schemas=(to_use_or_not_to_use) ⇒ Object
78 79 80 81 |
# File 'lib/apartment.rb', line 78 def use_postgres_schemas=(to_use_or_not_to_use) warn "[Deprecation Warning] `use_postgresql_schemas=` is now deprecated, please use `use_schemas=`" self.use_schemas = to_use_or_not_to_use end |