Class: ROM::SQL::Association::OneToOne
Instance Attribute Summary
#as, #relation, #result, #source, #target
Instance Method Summary
collapse
#initialize, #qualify
Instance Method Details
#call(relations) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rom/sql/association/one_to_one.rb', line 8
def call(relations)
with_keys(relations) do |left_pk, right_fk|
right = relations[target.relation]
columns = right..qualified.to_a
relation = right
.inner_join(source, left_pk => right_fk)
.select(*columns)
.order(*right..project(*right.primary_key).qualified)
relation.with(attributes: relation..names)
end
end
|
#combine_keys(relations) ⇒ Object
23
24
25
|
# File 'lib/rom/sql/association/one_to_one.rb', line 23
def combine_keys(relations)
Hash[*with_keys(relations)]
end
|
#join_keys(relations) ⇒ Object
28
29
30
31
32
|
# File 'lib/rom/sql/association/one_to_one.rb', line 28
def join_keys(relations)
with_keys(relations) { |source_key, target_key|
{ qualify(source, source_key) => qualify(target, target_key) }
}
end
|