module Dart::NamingConventions::ManyToManyAssociationHelpers
Public Instance Methods
conventional_name()
click to toggle source
Returns the name of a referenced association according to the naming convention
@return [String] the name of the referenced association
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 10 def conventional_name # just return e.g. 'groups' if right_ass.foreign_key is group_id naming_conventions.plural_association_name(right_ass.foreign_key) end
disambiguate_name!()
click to toggle source
forces long-form name to disambiguate from other joins to same association, where short-form name is the same
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 33 def disambiguate_name! unless is_semi_conventional_join_table? # add a foreign_key disambiguator when the key referencing me is unconventional set_name! naming_conventions.long_association_name(join_table, left_ass.foreign_key, left_ass.parent_table, right_ass.foreign_key) end end
left_foreign_key_is_conventional?()
click to toggle source
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 24 def left_foreign_key_is_conventional? left_ass.conventional_foreign_key? end
name_and_right_foreign_key_are_conventional?()
click to toggle source
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 19 def name_and_right_foreign_key_are_conventional? # name == associated_table == naming_conventions.parent_table_for(right_ass.foreign_key) name_is_conventional? && right_foreign_key_is_conventional? end
name_is_conventional?()
click to toggle source
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 15 def name_is_conventional? name == associated_table end
right_foreign_key_is_conventional?()
click to toggle source
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 28 def right_foreign_key_is_conventional? right_ass.conventional_foreign_key? end
Private Instance Methods
is_semi_conventional_join_table?()
click to toggle source
Returns true if the table joining t1 and t2 is semi-conventional, i.e. some variation of t1_t2 or t2_t1, for plural or singular forms of t1 and t2
# File lib/dart/naming_conventions/many_to_many_association_helpers.rb, line 44 def is_semi_conventional_join_table? @semi_conventional_join_table ||= begin naming_conventions.conventional_join_table_names(left_ass.parent_table, right_ass.parent_table).include?(join_table) end end