Sha256: c41d073cdb53323d56901edc0d54b196f35d9eb3da8686d1e273f801d9cafc64

Contents?: true

Size: 699 Bytes

Versions: 15

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module ROM
  module SQL
    module Associations
      # Core SQL association API
      #
      # @api private
      module Core
        # @api private
        def preload(target, loaded)
          source_key, target_key = join_keys.flatten(1)

          target_pks = loaded.pluck(source_key.key)
          target_pks.uniq!

          target.where(target_key => target_pks)
        end

        # @api private
        def wrapped
          new_target = view ? target.send(view) : target
          to_wrap = self.class.allocate
          to_wrap.send(:initialize, definition, **options, target: new_target)
          to_wrap.wrap
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rom-sql-3.7.0 lib/rom/sql/associations/core.rb
rom-sql-3.6.5 lib/rom/sql/associations/core.rb
rom-sql-3.6.4 lib/rom/sql/associations/core.rb
rom-sql-3.6.3 lib/rom/sql/associations/core.rb
rom-sql-3.6.2 lib/rom/sql/associations/core.rb
rom-sql-3.6.1 lib/rom/sql/associations/core.rb
rom-sql-3.6.0 lib/rom/sql/associations/core.rb
rom-sql-4.0.0.alpha1 lib/rom/sql/associations/core.rb
rom-sql-3.5.0 lib/rom/sql/associations/core.rb
rom-sql-3.4.0 lib/rom/sql/associations/core.rb
rom-sql-3.3.3 lib/rom/sql/associations/core.rb
rom-sql-3.3.2 lib/rom/sql/associations/core.rb
rom-sql-3.3.1 lib/rom/sql/associations/core.rb
rom-sql-3.3.0 lib/rom/sql/associations/core.rb
rom-sql-3.2.0 lib/rom/sql/associations/core.rb