Sha256: 6d2cf6e7bb4c12cd29ef83ebdbeae8fdb060b6341f034f7357a83ffc27f065ac

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

module Hanami
  module Providers
    # @api private
    # @since 2.2.0
    class Relations < Dry::System::Provider::Source
      def start
        start_and_import_parent_relations and return if target.parent && target.config.db.import_from_parent

        target.start :db

        register_relations target["db.rom"]
      end

      private

      def register_relations(rom)
        rom.relations.each do |name, _|
          register name, rom.relations[name]
        end
      end

      def start_and_import_parent_relations
        target.parent.start :relations

        register_relations target.parent["db.rom"]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-2.2.0.beta1 lib/hanami/providers/relations.rb