Module: Switchman

Defined in:
lib/switchman.rb,
lib/switchman/arel.rb,
lib/switchman/rails.rb,
lib/switchman/shard.rb,
lib/switchman/engine.rb,
lib/switchman/errors.rb,
lib/switchman/version.rb,
lib/switchman/parallel.rb,
lib/switchman/call_super.rb,
lib/switchman/guard_rail.rb,
lib/switchman/environment.rb,
lib/switchman/test_helper.rb,
lib/switchman/default_shard.rb,
lib/switchman/r_spec_helper.rb,
lib/switchman/standard_error.rb,
lib/switchman/database_server.rb,
lib/switchman/unsharded_record.rb,
lib/switchman/active_record/base.rb,
lib/switchman/guard_rail/relation.rb,
lib/switchman/shared_schema_cache.rb,
lib/switchman/active_support/cache.rb,
lib/switchman/sharded_instrumenter.rb,
lib/switchman/active_record/relation.rb,
lib/switchman/active_record/migration.rb,
lib/switchman/active_record/reflection.rb,
lib/switchman/action_controller/caching.rb,
lib/switchman/active_record/persistence.rb,
lib/switchman/active_record/query_cache.rb,
lib/switchman/active_record/type_caster.rb,
lib/switchman/active_record/associations.rb,
lib/switchman/active_record/calculations.rb,
lib/switchman/active_record/model_schema.rb,
lib/switchman/active_record/query_methods.rb,
lib/switchman/active_record/spawn_methods.rb,
lib/switchman/active_record/test_fixtures.rb,
lib/switchman/active_record/finder_methods.rb,
lib/switchman/active_record/log_subscriber.rb,
lib/switchman/active_record/connection_pool.rb,
lib/switchman/active_record/statement_cache.rb,
lib/switchman/active_record/abstract_adapter.rb,
lib/switchman/active_record/table_definition.rb,
lib/switchman/active_record/attribute_methods.rb,
lib/switchman/active_record/predicate_builder.rb,
lib/switchman/active_record/connection_handler.rb,
lib/switchman/active_record/postgresql_adapter.rb,
lib/switchman/active_record/tasks/database_tasks.rb,
lib/switchman/active_record/database_configurations.rb,
lib/switchman/active_record/pending_migration_connection.rb,
lib/switchman/active_record/database_configurations/database_config.rb

Defined Under Namespace

Modules: ActionController, ActiveRecord, ActiveSupport, Arel, CallSuper, Errors, GuardRail, Parallel, RSpecHelper, Rails, StandardError, TestHelper Classes: DatabaseServer, DefaultShard, Engine, Environment, OrderOnMultiShardQuery, Shard, ShardedInstrumenter, SharedSchemaCache, UnshardedRecord

Constant Summary collapse

Deprecation =
::ActiveSupport::Deprecation.new("4.0", "Switchman")
VERSION =
"3.6.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject



31
32
33
# File 'lib/switchman.rb', line 31

def cache
  (@cache.respond_to?(:call) ? @cache.call : @cache) || ::Rails.cache
end

Class Method Details

.configObject



26
27
28
29
# File 'lib/switchman.rb', line 26

def config
  # TODO: load from yaml
  @config ||= {}
end

.foreign_key_check(name, type, limit: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/switchman.rb', line 39

def foreign_key_check(name, type, limit: nil)
  return unless name.to_s.end_with?("_id") && type.to_s == "integer" && limit.to_i < 8

  puts <<~TEXT.squish
    WARNING: All foreign keys need to be 8-byte integers.
    #{name} looks like a foreign key.
    If so, please add the option: `:limit => 8`
  TEXT
end

.regionObject



35
36
37
# File 'lib/switchman.rb', line 35

def region
  config[:region]
end