Class: DuckRecord::Associations::Builder::HasOne

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

Overview

:nodoc:

Constant Summary

Constants inherited from Association

Association::VALID_OPTIONS

Class Method Summary collapse

Methods inherited from SingularAssociation

define_accessors, define_constructors

Methods inherited from Association

build, create_reflection, define_accessors, define_callbacks, define_extensions, define_readers, define_writers, valid_options, validate_options

Class Method Details

.define_validations(model, reflection) ⇒ Object



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

def self.define_validations(model, reflection)
  super

  if reflection.options[:required]
    model.validates_presence_of reflection.name, message: :required
  end
end

.macroObject



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

def self.macro
  :has_one
end