Class: Torque::PostgreSQL::Reflection::BelongsToManyReflection

Inherits:
ActiveRecord::Reflection::AssociationReflection show all
Defined in:
lib/torque/postgresql/reflection/belongs_to_many_reflection.rb,
sig/torque/postgresql/reflection/belongs_to_many_reflection.rbs

Instance Method Summary collapse

Methods included from AssociationReflection

#initialize

Instance Method Details

#active_record_primary_key ⇒ String?

Returns:

  • (String, nil)


35
36
37
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 35

def active_record_primary_key
  @active_record_primary_key ||= options[:primary_key]&.to_s || derive_primary_key
end

#array_attribute ⇒ arel_attribute

Returns:

  • (arel_attribute)


47
48
49
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 47

def array_attribute
  active_record.arel_table[foreign_key]
end

#association_class ⇒ singleton(Associations::BelongsToManyAssociation)



23
24
25
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 23

def association_class
  Associations::BelongsToManyAssociation
end

#association_foreign_key ⇒ String

Returns:

  • (String)


31
32
33
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 31

def association_foreign_key
  @association_foreign_key ||= foreign_key
end

#belongs_to? ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 15

def belongs_to?
  true
end

#collection? ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 19

def collection?
  true
end

#connected_through_array? ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 11

def connected_through_array?
  true
end

#foreign_key ⇒ String

Returns:

  • (String)


27
28
29
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 27

def foreign_key
  @foreign_key ||= options[:foreign_key]&.to_s || derive_foreign_key.freeze
end

#join_foreign_key ⇒ String

Returns:

  • (String)


43
44
45
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 43

def join_foreign_key
  foreign_key
end

#join_primary_key ⇒ String?

Parameters:

  • (Object)

Returns:

  • (String, nil)


39
40
41
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 39

def join_primary_key(*)
  active_record_primary_key
end

#macro ⇒ :belongs_to_many

Returns:

  • (:belongs_to_many)


7
8
9
# File 'lib/torque/postgresql/reflection/belongs_to_many_reflection.rb', line 7

def macro
  :belongs_to_many
end