Skip to content

Draft: Prevent instantiation of Namespace objects

charlie ablett requested to merge 341070-cablett-abstract-namespace-class into master

What does this MR do and why?

An experiment in preventing instantiation of Namespace objects.

This works for me in console:

> Namespace.new
=> #<Namespaces::UserNamespace:0x000055f82cd40588
 id: nil,
 name: nil,
 path: nil,
 owner_id: nil,
 created_at: nil,
 updated_at: nil,
 type: "User",
#... <snip>

it also works for becomes:

> Namespaces::ProjectNamespace.new.becomes(Namespace)
RuntimeError: Cannot directly instantiate a Namespace
from /home/charlie/Projects/gitlab-development-kit/gitlab/app/models/namespace.rb:9:in `initialize'

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #341070 (closed)

Edited by charlie ablett

Merge request reports