module Traits::Association::Join
Public Instance Methods
from_key()
click to toggle source
# File lib/traits/association/join.rb, line 19 def from_key from_table[from_key_name] end
from_key_name()
click to toggle source
# File lib/traits/association/join.rb, line 23 def from_key_name if polymorphic? reflection.foreign_key.to_sym elsif through? through_association.from_key_name elsif features.try(:translates_with_globalize?) nil elsif belongs_to? reflection.foreign_key.to_sym end || reflection.active_record_primary_key.to_sym end
from_table()
click to toggle source
# File lib/traits/association/join.rb, line 7 def from_table from.arel end
from_table_alias()
click to toggle source
# File lib/traits/association/join.rb, line 15 def from_table_alias from_table.table_alias.try(:to_sym) end
from_table_name()
click to toggle source
# File lib/traits/association/join.rb, line 11 def from_table_name from_table.name.to_sym end
to_hash()
click to toggle source
Calls superclass method
# File lib/traits/association/join.rb, line 79 def to_hash super.merge!( from_table_name: from_table_name, from_table_alias: from_table_alias, from_key_name: from_key_name, to_table_name: to_table_name, to_table_alias: to_table_alias, to_key_name: to_key_name ) end
to_key()
click to toggle source
# File lib/traits/association/join.rb, line 61 def to_key to_table.try(:[], to_key_name) end
to_key_name()
click to toggle source
# File lib/traits/association/join.rb, line 65 def to_key_name unless polymorphic? if through? source_association.to_key_name elsif belongs_to? || has_and_belongs_to_many? reflection.association_primary_key.to_sym else reflection.foreign_key.to_sym end end end
to_table()
click to toggle source
# File lib/traits/association/join.rb, line 39 def to_table unless polymorphic? table = to.arel.clone if self_to_self? table.table_alias = "#{plural_name}_#{from.table_name}" end table end end
to_table_alias()
click to toggle source
# File lib/traits/association/join.rb, line 55 def to_table_alias unless polymorphic? to_table.table_alias.try(:to_sym) end end
to_table_name()
click to toggle source
# File lib/traits/association/join.rb, line 49 def to_table_name unless polymorphic? to_table.name.to_sym end end