Sha256: 6b098c0e6ba33f14bdb3c96a91ef8d26996082007c4cde05781afe0dac70949b
Contents?: true
Size: 771 Bytes
Versions: 37
Compression:
Stored size: 771 Bytes
Contents
# frozen_string_literal: true module ActiveRecord::Associations::Builder # :nodoc: class HasOne < SingularAssociation #:nodoc: def self.macro :has_one end def self.valid_options(options) valid = super + [:as] 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 def self.define_validations(model, reflection) super if reflection.options[:required] model.validates_presence_of reflection.name, message: :required end end end end
Version data entries
37 entries across 37 versions & 4 rubygems