class Dbee::Model::Relationships::Basic

A relationship from one model to another.

Attributes

constraints[R]
model[R]
name[R]

Public Class Methods

new(name:, constraints: [], model: nil) click to toggle source
# File lib/dbee/model/relationships/basic.rb, line 19
def initialize(name:, constraints: [], model: nil)
  @name = name
  raise ArgumentError, 'name is required' if name.to_s.empty?

  @constraints = Constraints.array(constraints || []).uniq
  @model = model

  freeze
end

Public Instance Methods

==(other) click to toggle source
# File lib/dbee/model/relationships/basic.rb, line 37
def ==(other)
  other.instance_of?(self.class) &&
    other.name == name &&
    other.constraints == constraints &&
    other.model == model
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/dbee/model/relationships/basic.rb, line 33
def hash
  [self.class.hash, name.hash, constraints.hash, model.hash].hash
end
model_name() click to toggle source
# File lib/dbee/model/relationships/basic.rb, line 29
def model_name
  model || name
end