Follow-up from "Move Design Management `lib` files to FOSS"
The following discussion from !31554 (merged) should be addressed:
-
@.luke started a discussion: (+2 comments) I'd rather not switch off this cop, but I can't think of a way to refactor this method and retain clarity!
@splattael suggested in !31554 (diffs, comment 340476294):
Non-blocking: We could use a hash map:
# Naming, huh? :sweat_smile: CLASS_TO_URL_MAP = { ::Ci::Build => proc { |object, **options| instance.project_job_url(object.project, object, **options) }, Commit => proc { |object, **options| commit_url(object, **options) }, ... } ... def build(object, **options) # Objects are sometimes wrapped in a BatchLoader instance url_proc = CLASS_TO_URL_MAP.fetch(object.itself) do raise NotImplementedError.new("No URL builder defined for #{object.inspect}") end instance_exec(object, **options, &url_proc) end
> > This could work but I am not sure if it reads nicer sweat_smile: