Sha256: f59f00df641a9fddc1d5ffc48d17f17d88f3f07e10c4743f563e2d7ae8fb56d7
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require "rom/associations/abstract" module ROM module Associations # Abstract many-to-one association type # # @api public class ManyToOne < Abstract # Adapters must implement this method # # @abstract # # @api public def call(*) raise NotImplementedError end # Return configured or inferred FK name # # @return [Symbol] # # @api public def foreign_key definition.foreign_key || source.foreign_key(target.name) end # Associate child with a parent # # @param [Hash] child The child tuple # @param [Hash] parent The parent tuple # # @return [Hash] # # @api private def associate(child, parent) fk, pk = join_key_map child.merge(fk => parent.fetch(pk)) end protected # Return foreign key on the source side # # @return [Symbol] # # @api protected def source_key foreign_key end # Return primary key on the target side # # @return [Symbol] # # @api protected def target_key target.schema.primary_key_name end memoize :foreign_key end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/associations/many_to_one.rb |