Module: Switchman::ActiveRecord::Reflection::AssociationReflection

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

Instance Method Summary collapse

Instance Method Details

#association_scope_cache(conn, owner) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/switchman/active_record/reflection.rb', line 19

def association_scope_cache(conn, owner)
  key = conn.prepared_statements
  if polymorphic?
    key = [key, owner._read_attribute(@foreign_type)]
  end
  key = [key, owner.shard.id].flatten
  @association_scope_cache[key] ||= @scope_lock.synchronize {
    @association_scope_cache[key] ||= yield
  }
end

#join_id_for(owner) ⇒ Object



12
13
14
# File 'lib/switchman/active_record/reflection.rb', line 12

def join_id_for(owner)
  owner.send(active_record_primary_key) # use sharded id values in association binds
end

#quoted_table_nameObject



8
9
10
# File 'lib/switchman/active_record/reflection.rb', line 8

def quoted_table_name
  klass.quoted_table_name
end