Class: ActiveRecord::Reflection::BelongsToReflection

Inherits:
AssociationReflection show all
Defined in:
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, #association_class, #association_foreign_key, #association_primary_key, #association_scope_cache, #chain, #check_preloadable!, #check_validity!, #check_validity_of_inverse!, #collection?, #compute_class, #constructable?, #counter_cache_column, #foreign_key, #has_inverse?, #has_one?, #inverse_of, #join_table, #klass, #nested?, #polymorphic?, #polymorphic_inverse_of, #scope_chain, #source_reflection, #through_reflection, #validate?

Methods inherited from MacroReflection

#==, #autosave=, #compute_class, #klass

Methods inherited from AbstractReflection

#build_association, #class_name, #primary_key_type, #quoted_table_name, #source_macro, #table_name

Constructor Details

#initialize(name, scope, options, active_record) ⇒ BelongsToReflection

Returns a new instance of BelongsToReflection.



596
597
598
# File 'lib/active_record/reflection.rb', line 596

def initialize(name, scope, options, active_record)
  super(name, scope, options, active_record)
end

Instance Method Details

#belongs_to?Boolean

Returns:

  • (Boolean)


602
# File 'lib/active_record/reflection.rb', line 602

def belongs_to?; true; end

#join_id_for(owner) ⇒ Object

:nodoc:



609
610
611
# File 'lib/active_record/reflection.rb', line 609

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

#join_keys(assoc_klass) ⇒ Object



604
605
606
607
# File 'lib/active_record/reflection.rb', line 604

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

#macroObject



600
# File 'lib/active_record/reflection.rb', line 600

def macro; :belongs_to; end