Class: ROM::SQL::Associations::OneToMany

Inherits:
Associations::OneToMany
  • Object
show all
Includes:
Core, SelfRef
Defined in:
lib/rom/sql/associations/one_to_many.rb

Direct Known Subclasses

OneToOne

Instance Method Summary collapse

Methods included from SelfRef

included, #join_keys, #source_attr, #target_attr

Methods included from Core

#preload, #wrapped

Instance Method Details

#call(target: self.target) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/rom/sql/associations/one_to_many.rb', line 15

def call(target: self.target)
  schema = target.schema.qualified
  relation = target.join(source_table, join_keys)

  if view
    apply_view(schema, relation)
  else
    schema.(relation)
  end
end

#join(type, source = self.source, target = self.target) ⇒ Object



27
28
29
# File 'lib/rom/sql/associations/one_to_many.rb', line 27

def join(type, source = self.source, target = self.target)
  source.__send__(type, target.name.dataset, join_keys).qualified
end