Class: ActiveRecord::Associations::Builder::BelongsTo

Inherits:
SingularAssociation show all
Defined in:
activerecord/lib/active_record/associations/builder/belongs_to.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Association

#name, #options, #scope

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SingularAssociation

define_constructors

Methods inherited from Association

build, #build, create_builder, #define_extensions, define_readers, define_writers, #initialize, #validate_options

Constructor Details

This class inherits a constructor from ActiveRecord::Associations::Builder::Association

Class Method Details

.define_accessors(mixin, reflection) ⇒ Object



21
22
23
24
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 21

def self.define_accessors(mixin, reflection)
  super
  add_counter_cache_methods mixin
end

.define_callbacks(model, reflection) ⇒ Object



15
16
17
18
19
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 15

def self.define_callbacks(model, reflection)
  super
  add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
  add_touch_callbacks(model, reflection)         if reflection.options[:touch]
end

.valid_dependent_optionsObject



11
12
13
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 11

def self.valid_dependent_options
  [:destroy, :delete]
end

Instance Method Details

#macroObject



3
4
5
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 3

def macro
  :belongs_to
end

#valid_optionsObject



7
8
9
# File 'activerecord/lib/active_record/associations/builder/belongs_to.rb', line 7

def valid_options
  super + [:foreign_type, :polymorphic, :touch, :counter_cache]
end