Class: ActiveRecord::Associations::Builder::HasOne

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Association

#model, #name, #options, #reflection, #scope

Instance Method Summary collapse

Methods inherited from SingularAssociation

#define_accessors, #define_constructors

Methods inherited from Association

build, #build, #define_accessors, #define_readers, #define_writers, #initialize, #mixin, #validate_options

Constructor Details

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

Instance Method Details

#configure_dependencyObject



17
18
19
# File 'lib/active_record/associations/builder/has_one.rb', line 17

def configure_dependency
  super unless options[:through]
end

#constructable?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/active_record/associations/builder/has_one.rb', line 13

def constructable?
  !options[:through]
end

#macroObject



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

def macro
  :has_one
end

#valid_dependent_optionsObject



21
22
23
# File 'lib/active_record/associations/builder/has_one.rb', line 21

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

#valid_optionsObject



7
8
9
10
11
# File 'lib/active_record/associations/builder/has_one.rb', line 7

def valid_options
  valid = super + [:order, :as]
  valid += [:through, :source, :source_type] if options[:through]
  valid
end