Class: Formed::Reflection::BelongsToReflection

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from AssociationReflection

#foreign_type, #parent_reflection, #type

Attributes inherited from MacroReflection

#active_form, #name, #options, #plural_name, #scope

Instance Method Summary collapse

Methods inherited from AssociationReflection

#add_as_polymorphic_through, #add_as_source, #add_as_through, #association_foreign_key, #check_eager_loadable!, #check_validity!, #collect_join_chain, #collection?, #compute_class, #extensions, #foreign_key, #has_inverse?, #has_one?, #has_scope?, #initialize, #join_table, #nested?, #polymorphic?, #polymorphic_inverse_of, #source_reflection, #through_reflection, #validate?

Methods inherited from MacroReflection

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

Methods inherited from AbstractReflection

#alias_candidate, #build_association, #build_scope, #chain, #check_validity_of_inverse!, #class_name, #constraints, #inverse_of, #scopes, #strict_loading?, #strict_loading_violation_message, #table_name, #through_reflection?

Constructor Details

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

Instance Method Details

#association_classObject



617
618
619
620
621
622
623
# File 'lib/formed/reflection.rb', line 617

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

#association_primary_key(klass = nil) ⇒ Object

klass option is necessary to support loading polymorphic associations



626
627
628
629
630
631
632
# File 'lib/formed/reflection.rb', line 626

def association_primary_key(klass = nil)
  if (primary_key = options[:primary_key])
    @association_primary_key ||= -primary_key.to_s
  else
    primary_key(klass || self.klass)
  end
end

#belongs_to?Boolean



613
614
615
# File 'lib/formed/reflection.rb', line 613

def belongs_to?
  true
end

#macroObject



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

def macro
  :belongs_to
end