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

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

Instance Method Summary collapse

Instance Method Details

#shard(owner) ⇒ Object



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

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