Sha256: 6829b0c83fce8ec29c644ee5f1feadaedfcc9ce0bb067e1c7f9503ada1cdc301

Contents?: true

Size: 1.95 KB

Versions: 4

Compression:

Stored size: 1.95 KB

Contents

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
    
    # configure apartment with available options
    def configure
      yield self if block_given?
    end
    
    # Be careful not to use `return` here so both Proc and lambda can be used without breaking
    def database_names
      @database_names.respond_to?(:call) ? @database_names.call : @database_names
    end
    
    # Default to none
    def excluded_models
      @excluded_models || []
    end
    
  end
  
  autoload :Database, 'apartment/database'
  autoload :Migrator, 'apartment/migrator'
  autoload :Reloader, 'apartment/reloader'
  
  module Adapters
    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'
  end
  
  module Delayed
    
    autoload :Requirements, 'apartment/delayed_job/requirements'
    
    module Job
      autoload :Hooks, 'apartment/delayed_job/hooks'
    end
  end
  
  # Exceptions
  class ApartmentError < StandardError; end
  
  # Raised when apartment cannot find the adapter specified in <tt>config/database.yml</tt>
  class AdapterNotFound < ApartmentError; end
  
  # Raised when database cannot find the specified database
  class DatabaseNotFound < ApartmentError; end
  
  # Raised when trying to create a database that already exists
  class DatabaseExists < ApartmentError; end
  
  # Raised when database cannot find the specified schema
  class SchemaNotFound < ApartmentError; end
  
  # Raised when trying to create a schema that already exists
  class SchemaExists < ApartmentError; end
  
  # Raised when an ActiveRecord object does not have the required database field on it
  class DJSerializationError < ApartmentError; end
  
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
dr-apartment-0.14.1 lib/apartment.rb
apartment-0.14.2 lib/apartment.rb
apartment-0.14.1 lib/apartment.rb
apartment-0.14.0 lib/apartment.rb