[V2] => Extend YAML parsing to allow raw ruby objects

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

Given that [V2] =>Extend YAML parsing to allow variable re... (#390598 - closed) allows non-Ruby parsers to refer back to variables that were defined previously ...

These variables can only be attributes that belong to the model, not the model itself.

---
# x2 group labels. the second one refers back to the first
group_labels:
  - _id: my_label
    title: My Label
  - title: <%= group_labels.my_label.title %> #=> WORKS: My Label

epics:
  - group_id: <%= @group.id %> #=> WORKS
  - group: <%= @group %> #=> DOES NOT WORK: ActiveRecord::AssociationTypeMismatch: Group(#275480) expected, got "<%= @group %>" which is an instance of String(#12980)
    labels:
      - <%= group_labels.my_label %> #=> DOES NOT WORK: ActiveRecord::AssociationTypeMismatch: Label(#275480) expected, got "<%= group_labels.my_label %>" which is an instance of String(#12980)

Proposal

Allow references to raw ruby objects that are fabricated, that can be referred back to.

---
group_labels:
  - _id: my_label
    color: "#FF0000"

epics:
  - group: <%= @group %>
    labels:
      - <%= group_labels.my_label %> 
  - group: <%= @group %>
    labels: <%= group_labels %> #=> Stretch
Edited by 🤖 GitLab Bot 🤖