Module: Switchman::StandardError
- Defined in:
- lib/switchman/standard_error.rb
Instance Method Summary collapse
Instance Method Details
#current_shard(klass = ::ActiveRecord::Base) ⇒ Object
22 23 24 |
# File 'lib/switchman/standard_error.rb', line 22 def current_shard(klass = ::ActiveRecord::Base) @active_shards&.[](klass) || Shard.default end |
#initialize(*args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |