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



30
31
32
33
34
35
36
37
38
39
# File 'lib/switchman/active_record/reflection.rb', line 30

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

#join_id_for(owner) ⇒ Object



23
24
25
# File 'lib/switchman/active_record/reflection.rb', line 23

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

#quoted_table_nameObject



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

def quoted_table_name
  klass.quoted_table_name
end