module Switchman::StandardError
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/switchman/standard_error.rb, line 5 def initialize(*args) # Shard.current can throw this when switchman isn't working right; if we try to # do our stuff here, it'll cause a SystemStackError, which is a pain to deal with if is_a?(::ActiveRecord::ConnectionNotEstablished) super return end if defined?(Shard) @active_shards = Shard.sharded_models.map do |klass| [klass, Shard.current(klass)] end.compact.to_h end super end
Public Instance Methods
current_shard(klass = ::ActiveRecord::Base)
click to toggle source
# File lib/switchman/standard_error.rb, line 22 def current_shard(klass = ::ActiveRecord::Base) @active_shards&.[](klass) || Shard.default end