lib/apartment.rb in apartment-0.15.0 vs lib/apartment.rb in apartment-0.16.0
- old
+ new
@@ -1,13 +1,16 @@
require 'apartment/railtie' if defined?(Rails)
module Apartment
class << self
- attr_accessor :use_postgres_schemas, :seed_after_create, :prepend_environment
- attr_writer :database_names, :excluded_models
+ ACCESSOR_METHODS = [:use_postgres_schemas, :seed_after_create, :prepend_environment]
+ WRITER_METHODS = [:database_names, :excluded_models, :default_schema, :persistent_schemas]
+ attr_accessor(*ACCESSOR_METHODS)
+ attr_writer(*WRITER_METHODS)
+
# configure apartment with available options
def configure
yield self if block_given?
end
@@ -19,10 +22,23 @@
# Default to empty array
def excluded_models
@excluded_models || []
end
+ def default_schema
+ @default_schema || "public"
+ end
+
+ def persistent_schemas
+ @persistent_schemas || []
+ end
+
+ # Reset all the config for Apartment
+ def reset
+ (ACCESSOR_METHODS + WRITER_METHODS).each{|method| instance_variable_set(:"@#{method}", nil) }
+ end
+
end
autoload :Database, 'apartment/database'
autoload :Migrator, 'apartment/migrator'
autoload :Reloader, 'apartment/reloader'
@@ -31,10 +47,12 @@
autoload :AbstractAdapter, 'apartment/adapters/abstract_adapter'
# Specific adapters will be loaded dynamically based on adapter in config
end
module Elevators
- autoload :Subdomain, 'apartment/elevators/subdomain'
+ autoload :Generic, 'apartment/elevators/generic'
+ autoload :Subdomain, 'apartment/elevators/subdomain'
+ autoload :Domain, 'apartment/elevators/domain'
end
module Delayed
autoload :Requirements, 'apartment/delayed_job/requirements'