Sha256: 3c6066783855062586e604de054b4d5a0d72ccb27ec9888f7b51daf4c2cd17e6

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

module Foobara
  module RemoteImports
    class ImportType < Command
      include ImportBase

      depends_on ImportDomain, ImportType

      def find_manifests_to_import
        root_manifest.types
      end

      def import_object_from_manifest
        existing_type = Foobara.foobara_root_namespace.foobara_lookup_type(
          manifest_to_import.reference,
          mode: Namespace::LookupMode::ABSOLUTE
        )

        return if existing_type

        domain_manifest = manifest_to_import.domain

        run_subcommand!(
          ImportDomain,
          raw_manifest: manifest_data,
          to_import: domain_manifest.reference,
          already_imported:
        )

        domain_manifest = manifest_to_import.domain

        domain = if domain_manifest.global?
                   GlobalDomain
                 else
                   Foobara.foobara_root_namespace.foobara_lookup_domain!(
                     domain_manifest.reference,
                     mode: Namespace::LookupMode::ABSOLUTE
                   )
                 end

        manifest_to_import.types_depended_on.each do |depended_on_type|
          run_subcommand!(
            ImportType,
            raw_manifest: manifest_data,
            to_import: depended_on_type.reference,
            already_imported:
          )
        end

        containing_module_name = manifest_to_import.scoped_full_path[0..-2].join("::")
        unless containing_module_name.empty?
          Util.make_module_p(containing_module_name, tag: true)
        end

        type = domain.foobara_type_from_strict_stringified_declaration(manifest_to_import.declaration_data)
        domain.foobara_register_type(manifest_to_import.scoped_path, type)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foobara-remote-imports-0.0.2 src/foobara/remote_imports/import_type.rb
foobara-remote-imports-0.0.1 src/foobara/remote_imports/import_type.rb