Class: Dbee::Model::Constraints::Reference

Inherits:
Base
  • Object
show all
Defined in:
lib/dbee/model/constraints/reference.rb

Overview

A Reference constraint is a constraint between two data models. In DB terms: the name represents the column name on the child and the parent represents the column name on the parent table.

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#<=>, #==, #hash

Constructor Details

#initialize(name:, parent:) ⇒ Reference

Returns a new instance of Reference.

Raises:

  • (ArgumentError)


21
22
23
24
25
26
27
28
# File 'lib/dbee/model/constraints/reference.rb', line 21

def initialize(name:, parent:)
  raise ArgumentError, 'name is required' if name.to_s.empty?
  raise ArgumentError, 'parent is required' if parent.to_s.empty?

  super(name: name, parent: parent)

  freeze
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



19
20
21
# File 'lib/dbee/model/constraints/reference.rb', line 19

def parent
  @parent
end