Class: ActiveRecord::Associations::SingularAssociation
- Inherits:
 - 
      Association
      
        
- Object
 - Association
 - ActiveRecord::Associations::SingularAssociation
 
 
- Defined in:
 - lib/active_record/associations/singular_association.rb
 
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Association
Instance Method Summary collapse
- #build(attributes = {}, &block) ⇒ Object
 - 
  
    
      #force_reload_reader  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Implements the reload reader method, e.g.
 - 
  
    
      #reader  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Implements the reader method, e.g.
 - 
  
    
      #writer(record)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Implements the writer method, e.g.
 
Methods inherited from Association
#create, #create!, #extensions, #initialize, #initialize_attributes, #inversed_from, #klass, #load_target, #loaded!, #loaded?, #marshal_dump, #marshal_load, #reload, #remove_inverse_instance, #reset, #reset_scope, #scope, #set_inverse_instance, #set_inverse_instance_from_queries, #stale_target?
Constructor Details
This class inherits a constructor from ActiveRecord::Associations::Association
Instance Method Details
#build(attributes = {}, &block) ⇒ Object
      20 21 22 23 24  | 
    
      # File 'lib/active_record/associations/singular_association.rb', line 20 def build(attributes = {}, &block) record = build_record(attributes, &block) set_new_record(record) record end  | 
  
#force_reload_reader ⇒ Object
Implements the reload reader method, e.g. foo.reload_bar for Foo.has_one :bar
      28 29 30 31  | 
    
      # File 'lib/active_record/associations/singular_association.rb', line 28 def force_reload_reader reload(true) target end  | 
  
#reader ⇒ Object
Implements the reader method, e.g. foo.bar for Foo.has_one :bar
      7 8 9 10 11 12 13  | 
    
      # File 'lib/active_record/associations/singular_association.rb', line 7 def reader if !loaded? || stale_target? reload end target end  | 
  
#writer(record) ⇒ Object
Implements the writer method, e.g. foo.bar= for Foo.belongs_to :bar
      16 17 18  | 
    
      # File 'lib/active_record/associations/singular_association.rb', line 16 def writer(record) replace(record) end  |