Module: Switchman::ActiveRecord::Association

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

Instance Method Summary collapse

Instance Method Details

#build_record(*args) ⇒ Object



10
11
12
# File 'lib/switchman/active_record/association.rb', line 10

def build_record(*args)
  shard.activate { super }
end

#load_targetObject



14
15
16
# File 'lib/switchman/active_record/association.rb', line 14

def load_target
  shard.activate { super }
end

#scopeObject



18
19
20
21
# File 'lib/switchman/active_record/association.rb', line 18

def scope
  shard_value = @reflection.options[:multishard] ? @owner : shard
  @owner.shard.activate { super.shard(shard_value, :association) }
end

#shardObject



6
7
8
# File 'lib/switchman/active_record/association.rb', line 6

def shard
  reflection.shard(owner)
end