aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/has_one.rb
blob: 64e9e6b334143db87d5a0cca6b84a088151d66d8 (plain) (tree)
1
2
3
4
5
6
7
8

                                             
                  

              
 
                                   
                                          


                                                                     
 
                                    
                                                                                   
       
 
                                                     
                                               
       

     
module ActiveRecord::Associations::Builder
  class HasOne < SingularAssociation #:nodoc:
    def self.macro
      :has_one
    end

    def self.valid_options(options)
      valid = super + [:as, :foreign_type]
      valid += [:through, :source, :source_type] if options[:through]
      valid
    end

    def self.valid_dependent_options
      [:destroy, :delete, :nullify, :restrict_with_error, :restrict_with_exception]
    end

    def self.add_destroy_callbacks(model, reflection)
      super unless reflection.options[:through]
    end
  end
end