Module: Switchman::ActiveRecord::Reflection::AbstractReflection

Defined in:
lib/switchman/active_record/reflection.rb

Instance Method Summary collapse

Instance Method Details

#shard(owner) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/switchman/active_record/reflection.rb', line 7

def shard(owner)
  if polymorphic? || klass.connection_class_for_self == owner.class.connection_class_for_self
    # polymorphic associations assume the same shard as the owning item
    owner.shard
  else
    Shard.default
  end
end