Sha256: 122729d4fbcadc57ffae91bc6b52ea52a83578301ba0ae4db4d8af75f9990f08

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require "rom/schema"
require "rom/memory/associations"

module ROM
  module Memory
    # Specialized schema for memory adapter
    #
    # @api public
    class Schema < ROM::Schema
      # @see Schema#call
      # @api public
      def call(relation)
        relation.new(relation.dataset.project(*map(&:name)), schema: self)
      end

      # Internal hook used during setup process
      #
      # @see Schema#finalize_associations!
      #
      # @api private
      def finalize_associations!(relations:)
        super do
          associations.map do |definition|
            Memory::Associations.const_get(definition.type).new(definition, relations)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/memory/schema.rb