Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Extended by:
- ActiveRecordShards::ConfigurationParser, ActiveRecordShards::ConnectionSwitcher, ActiveRecordShards::DefaultSlavePatches, ActiveRecordShards::Model
- Defined in:
- lib/active_record_shards/connection_pool.rb,
lib/active_record_shards/connection_specification.rb
Constant Summary
Constants included from ActiveRecordShards::DefaultSlavePatches
ActiveRecordShards::DefaultSlavePatches::CLASS_SLAVE_METHODS
Class Method Summary collapse
Methods included from ActiveRecordShards::ConfigurationParser
configurations_with_shard_explosion=, expand_child!, explode, extended
Methods included from ActiveRecordShards::Model
extended, is_sharded?, not_sharded, on_slave_by_default=, on_slave_by_default?
Methods included from ActiveRecordShards::ConnectionSwitcher
connection_pool_name, current_shard_id, current_shard_selection, default_shard=, establish_connection_override, extended, on_all_shards, on_cx_switch_block, on_first_shard, on_master, on_master_if, on_master_or_slave, on_master_unless, on_shard, on_slave, on_slave?, on_slave_if, on_slave_unless, shard_names, supports_sharding?
Methods included from ActiveRecordShards::DefaultSlavePatches
Class Method Details
.arel_engine ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/active_record_shards/connection_pool.rb', line 46 def self.arel_engine @arel_engine ||= begin if self == ActiveRecord::Base Arel::Table.engine else connection_handler.connection_pools[connection_pool_name] ? self : superclass.arel_engine end end end |
.establish_connection(spec = ENV["DATABASE_URL"]) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/active_record_shards/connection_specification.rb', line 3 def self.establish_connection(spec = ENV["DATABASE_URL"]) resolver = ConnectionSpecification::Resolver.new spec, configurations spec = resolver.spec unless respond_to?(spec.adapter_method) raise AdapterNotFound, "database configuration specifies nonexistent #{spec.config[:adapter]} adapter" end remove_connection specification_cache[connection_pool_name] = spec connection_handler.establish_connection connection_pool_name, spec end |