Class: ActiveRecord::Reflection::BelongsToReflection

Inherits:
AssociationReflection show all
Defined in:
activerecord/lib/active_record/reflection.rb

Overview

:nodoc:

Constant Summary

Constants inherited from AssociationReflection

AssociationReflection::INVALID_AUTOMATIC_INVERSE_OPTIONS, AssociationReflection::VALID_AUTOMATIC_INVERSE_MACROS

Instance Attribute Summary

Attributes inherited from AssociationReflection

#foreign_type, #parent_reflection, #type

Attributes inherited from MacroReflection

#active_record, #name, #options, #plural_name, #scope

Instance Method Summary collapse

Methods inherited from AssociationReflection

#active_record_primary_key, #add_as_polymorphic_through, #add_as_source, #add_as_through, #association_foreign_key, #association_primary_key, #association_primary_key_type, #association_scope_cache, #check_preloadable!, #check_validity!, #clear_association_scope_cache, #collect_join_chain, #collection?, #compute_class, #constructable?, #foreign_key, #has_inverse?, #has_one?, #has_scope?, #initialize, #join_table, #klass, #nested?, #polymorphic?, #polymorphic_inverse_of, #scope_chain, #source_reflection, #through_reflection, #validate?

Methods inherited from MacroReflection

#==, #autosave=, #compute_class, #initialize, #klass, #scope_for

Methods inherited from AbstractReflection

#alias_candidate, #build_association, #chain, #check_validity_of_inverse!, #class_name, #constraints, #counter_cache_column, #counter_must_be_updated_by_has_many?, #has_cached_counter?, #inverse_of, #inverse_updates_counter_in_memory?, #inverse_which_updates_counter_cache, #primary_key_type, #quoted_table_name, #table_name, #through_reflection?

Constructor Details

This class inherits a constructor from ActiveRecord::Reflection::AssociationReflection

Instance Method Details

#association_classObject


670
671
672
673
674
675
676
# File 'activerecord/lib/active_record/reflection.rb', line 670

def association_class
  if polymorphic?
    Associations::BelongsToPolymorphicAssociation
  else
    Associations::BelongsToAssociation
  end
end

#belongs_to?Boolean

Returns:

  • (Boolean)

668
# File 'activerecord/lib/active_record/reflection.rb', line 668

def belongs_to?; true; end

#join_id_for(owner) ⇒ Object

:nodoc:


683
684
685
# File 'activerecord/lib/active_record/reflection.rb', line 683

def join_id_for(owner) # :nodoc:
  owner[foreign_key]
end

#join_keys(association_klass) ⇒ Object


678
679
680
681
# File 'activerecord/lib/active_record/reflection.rb', line 678

def join_keys(association_klass)
  key = polymorphic? ? association_primary_key(association_klass) : association_primary_key
  JoinKeys.new(key, foreign_key)
end

#macroObject


666
# File 'activerecord/lib/active_record/reflection.rb', line 666

def macro; :belongs_to; end